1

Trying to create a script to automate mounting CIFS shares as drives on windows 2008/2012 server. The share requires a login (Unfortunately, AD can not be used) and needs to be mounted as a persistent drive that survives reboots.

Windows allows below

net use x: \\10.243.212.19\demo_nas_share /USER:username password /PERSISTENT:YES

However above won't save credential for next boot. We need to use

net use x: \\10.243.212.19\demo_nas_share /SAVECRED /PERSISTENT:YES

But this cmd only accepts the login details via a prompt and difficult to call from the script. Not sure if default windows server install has a native tool like 'Expect' to automate this. I like to avoid installing a third party utility.

NOTE: You can not combine /USER and /SAVECRED. This apparently was supported in some older version of windows though.

The other commonly suggested solutions is to put the cmd into startup folder. But I don't want to expose the password in plain text.

Can anyone recommend a native solution ?

1
  • 2
    So you can't expose the password but you also can't use AD? That's the exact problem that Kerberos integration into AD solves. Why not just implement AD properly?
    – MDMarra
    Jul 31, 2013 at 18:57

3 Answers 3

0

Just a thought but you could just dump your command into a batch file and set it as a logon script in the local gpo.

@echo off

If exist x: goto Remove

goto Map

:Remove

net use x: /DELETE

:Map

net use x: \10.243.212.19\demo_nas_share /USER:username password

:End

1
  • This would work, but the password would still be visible in plain text in the file. Jul 31, 2013 at 19:21
0

You could script the drive mapping in VBScript, and then use the Microsoft Script Encoder to encode it - this would prevent the password from being visible in plain text in the file, but be aware that the encoding is pretty easy to reverse.

This file can then be used as a logon script in a local group policy in the same way that w33mhz suggests.

A howto on encoding scripts is available here

0

Sort AD. Use Group Policy Preferences to map a drive. Simples...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .