Solved

vbscript not working

Posted on 2011-02-16
12
562 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:SView
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 4

Expert Comment

by:ChuckDeezel
ID: 34907669
If the remote share authenticates using the windows domain/login informaiton, then why not try leaving the password arguements out of the script completely?
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 34907687
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?
0
 
LVL 4

Expert Comment

by:FireW0lf
ID: 34907726
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
0
 
LVL 1

Author Comment

by:SView
ID: 34908805
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.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 34909999
"...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
0
 
LVL 16

Expert Comment

by:cantoris
ID: 34911828
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.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:SView
ID: 34943902
I qualified the hostname and it still didnt work.  How would i make the map persistent on my script.
0
 
LVL 16

Expert Comment

by:cantoris
ID: 34944485
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.
0
 
LVL 1

Author Comment

by:SView
ID: 34953008
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......
0
 
LVL 1

Author Comment

by:SView
ID: 34953016
Cantoris: I tried your script and it didnt work.
0
 
LVL 16

Accepted Solution

by:
cantoris earned 125 total points
ID: 34953841
Sorry, I missed the drive letter out in the net use

eg   "net use f: \\server\share /user:testuser password"
0
 
LVL 1

Author Comment

by:SView
ID: 34956065
Applied to AD logon and worked... thanks
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now