Why is this script not mapping my W drive?

Why is this script not mapping my W drive?
Set objNetwork = CreateObject("WScript.Network")
If ucase(objNetwork.ComputerName) = "acsms02" Then
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Tools\Software"
   objNetwork.MapNetworkDrive "w:", "\\acsms02\users\" & objnetwork.UserName
Else
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
End If

Open in new window

LVL 1
ipcipherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tuttlepcCommented:
i would try declaring objnetwork.UserName as a variable and using the variable instead of objnetwork.UserName where you have>> objNetwork.MapNetworkDrive "w:", "\\acsms02\users\" & objnetwork.UserName
0
Shift-3Commented:
The problem is that you specified ucase on Line 2 but entered the name in lowercase.  This condition will never be true.

Try changing it to LCase.
0
tuttlepcCommented:
doh! i totally missed that one...
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

ipcipherAuthor Commented:
So how can i get it to work? I am new to vbscript.
0
Shift-3Commented:
On Line 2, "ucase(objNetwork.ComputerName)" takes the computername and converts it to all uppercase letters.  To correct the problem, either change this to "LCase(objNetwork.ComputerName)" or change "acsms02" to "ACSMS02".
0
ipcipherAuthor Commented:
I am using this code and i still cant get the W drive mapped when i login to acsms02. Any ideas?
Set objNetwork = CreateObject("WScript.Network")
If ucase(objNetwork.ComputerName) = "ACSMS02" Then
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Tools\Software"
   objNetwork.MapNetworkDrive "w:", "\\acsms02\users\" & objnetwork.UserName
Else
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
End If

Open in new window

0
tuttlepcCommented:
open up my computer
and in the top type in
if you type in \\acsdm02\users\yourusername  

does it work? do you see your files?
0
ipcipherAuthor Commented:
Yes i can see my files.
0
tuttlepcCommented:
ok, like i was saying b4... you need to do something like this....

Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
strPath = "C:\Documents and Settings\" & strUser
0
tuttlepcCommented:
you're declaring objNetwork.UserName as a variable and using that variable in the path of where you're trying map the drive....

vs trying to obtain the value after the fact... there's a term for it...

so yours would look something like this
strUser = objNetwork.UserName
objNetwork.MapNetworkDrive "w:", "\\acsms02\users\" & strUser

give that a try and let me know if works?


0
ipcipherAuthor Commented:
Ok i have modified the code, and doesn't map the w: drive.  I get an error on line 4 char 4 error no network provider accepted the given network path.
Set objNetwork = CreateObject("WScript.Network")
strUser = objNetwork.UserName
If ucase(objNetwork.ComputerName) = "ACSMS02" Then
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Tools\Software"
   objNetwork.MapNetworkDrive "W:", "\\acsms02\users\" & strUser
Else
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
End If

Open in new window

0
tuttlepcCommented:
no, it won't see it unless you put the strUser inside the if statement... i think
0
tuttlepcCommented:
why are you using an if statement anyway? take that out... for the time being simplify it...

then go put it back in...
0
tuttlepcCommented:
try that maybe?
1:
2:
3:
4:
5:
6:
7:
8:
 
	
 
Set objNetwork = CreateObject("WScript.Network")
If ucase(objNetwork.ComputerName) = "ACSMS02" Then
strUser = objNetwork.UserName
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Tools\Software"
   objNetwork.MapNetworkDrive "W:", "\\acsms02\users\" & strUser
Else
   objNetwork.MapNetworkDrive "F:", "\\acsms01\Data\ds4"
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.