Link to home
Start Free TrialLog in
Avatar of SView
SViewFlag for United States of America

asked on

vbscript not working

Hi all...
We have a network drive that's causing some issues.  I wrote a vbscript to map the drive and applied it to each OU/user as necessary.  After the next reboot the workstations show the network drive but when you click on it, it needs the password entered. Here is the script I'm using...
Dim objNetwork
Dim strDriveLetter
Dim strRemotePath
Dim strUserName
Dim strPassWord
strDriveLetter = "W:"
strRemotePath = "\\xxx.xxx.x.x\xxx"
Set objNetwork = CreateObject("WScript.Network")
strUserName = "xxxxxx"
strPassWord = "xxxxxx"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath,True, strUserName, strPassWord

Is there something wrong with my script that its not saving the password?  
FYI Win Server 2003 R2 domain/Mapped drive on Linux server using samba
Thanks in advance!
-cp
Avatar of ChuckDeezel
ChuckDeezel

If the remote share authenticates using the windows domain/login informaiton, then why not try leaving the password arguements out of the script completely?
Avatar of Paul MacDonald
Are you certain the user/password combination has permissions to the drive?  That is if you map the drive manually once the user is logged in, does that combination work?
One thing: Is this being applied at each logon via GPO? If so, then it will error out because those drives will already be mapped from the previous day - you need to perform an "If drive letter exists, disconnect it" first
Avatar of SView

ASKER

If i map the drive manually (via windows) the drive stays attached until the workstation restarts.  Upon restarting the drive missing.....When i apply the script to the user via AD the drive is there, just the user has to put in the password. I'm going to remove the script from the OU to remove any variables......
As for removing the password, due to certain circumstances beyond my control, that's not gonna work.
"...the drive stays attached until the workstation restarts."  Even if you make the map persistent?  The problem may be on the Linux/Samba end, then
What about strUserName = "remotehostname\username" (presuming it's a local account on that server)?

I've had issues where you have to qualify the hostname like that when a script is run through some methods but not in others.
Avatar of SView

ASKER

I qualified the hostname and it still didnt work.  How would i make the map persistent on my script.
Isn't the "True" in your command making it persistent by storing it in the profile or am I misunderstanding that?

Have you tried using this?
Set objWshShell = CreateObject("WScript.Shell")
objWshShell.Run "net use \\server\path /user:user pwd", 0, True

Open in new window

I know it's a mess compared to just WMI but might be useful for diagnostics.
Avatar of SView

ASKER

Update.....
I got the script working for one AD account via log on script and gpo.  The other AD account i have tried the same and it does not work.  I have put the script on their desktop for them to execute for when they need it......
Avatar of SView

ASKER

Cantoris: I tried your script and it didnt work.
ASKER CERTIFIED SOLUTION
Avatar of cantoris
cantoris
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SView

ASKER

Applied to AD logon and worked... thanks