VB Script - Map network drive - remember credentials Hi wondering if anyone can help me out with this.. Seems that our admins have made a change to the GPO for Windows not to remember credentials when mapping network drives.
I have no problem mapping a network drive manually, by selecting Connect using different credentials, then on the following input box entering user name, password, and checking off Remember My Credentials.
But I was looking to automate this using VBScript so I don't have to explain it to the user, the script works on machines that don't have the GPO applied, but if they do have it applied I can't figure out how to tell windows to remember my credentials:
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = InputBox("Drive letter to map to:" & (Chr(13) & Chr(10) & Chr(13)) & "EG: Z","Drive letter prompt")
strLocalDrive = strLocalDrive +":"
strRemoteShare = InputBox ("Path and Share" & (Chr(13) & Chr(10) & Chr(13)) & "EG:\\ip.ip.ip.ip\rpg\group","Share path prompt","\\server\path")
strPer = "FALSE"
strUsr = InputBox("Username for mapped drive:","Username prompt",strUserName)
strPas = InputBox("Password for mapped drive:","Password prompt")
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strPas
JBEveryday Normal GuyReviews:
What else is contained in the GPO? If it works for people w/o the GPO applied makes me think the script is working right and there's something conflicting in the GPO.
Having said that, I have only looked at VBScript a couple of time, so I'm not much help with the code above, sorry.
Here's the final bullet,
to put our love to death.
exocet_cmI am the law - Judge DreddPremium
New Orleans, LA
reply to activoice
What version of server are you using?
Would it be possible to tailor GPOs to OUs and set the drive maps in group policy preferences (assuming server 2k8)? I use to script a lot but when I realized how easy it was to do this with preferences in 2008 R2 I ditched the scripts and did all the mapping in the GPOs.
"I have measured out my life with coffee spoons..." - T.S Eliot
"I have often regretted my speech, never my silence." - Publilius Syrus
Ma blog: »www.johndball.com
I assume it's probably server 2008, but I believe that the GPO setting is done on windows 7. I'm basically an end user without admin rights trying to script around something the admins have locked down.
I've done a lot of google searches and can't find anything related to that setting, leading me to believe that it can't be scripted.
reply to activoice
Depending on your security environment, you could use something like Autoit to pass the credentials when opening a share - and you could probably use an encryption library to store the users credentials - though you are still storing the credentials somewhere...
Yea, you'd use a library function like _Crypt_EncryptData and then choose to either embed the decrypt password in the script that you compile (if people trust you to not go snarf up their credentials)...
Opera 12.01; Windows XP Pro SP3;Intel C2Q6600; 3GB DDR2 1066; 1M/128k DSL; Comodo Internet Security 5.3;Proxomitron 4.5j Sidki 2009-06-06,GPG ID:0x0A1C6EE3