Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with conditional drive mapping...

Status
Not open for further replies.

kbeaton

IS-IT--Management
Jul 21, 2009
3
US
I need to create a logon script for XP Pro machines and MS 2003 Server.

This is the part I am currently stuck on.
++++++++++++++++++++++++++++++
Dim WSHNetwork
If (mid(UCase(strComputer), 3, 2) = "LT") Then
WSHNetwork.MapNetworkDrive "P:", "\\"&strComputer&"\Procede",True
Else
WSHNetwork.MapNetworkDrive "P:", "\\prosperity\SharedData\CommonShare"
End if
++++++++++++++++++++++++++++++

But I get this error
++++++++++++++++++++++++++++++
Line: 6
Char: 1
Error: Object required: "
Code: 800A01A8
++++++++++++++++++++++++++++++

Can someone help me out?

Thanks

Kelvin
 
You have to [!]Set[/!] WSHNetwork ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I get this error now.
++++++++++++++++++++++++
Line: 6
Char: 1
Error: Type mismatch: '[string:""]'
Code: 800A000D

It the line that starts with "If Mid..."
++++++++++++++++++++++++
Dim WSHNetwork

Set WSHNetwork = CreateObject("WScript.Network")
strComputer = WSHNetwork.ComputerName

If mid((UCase(strComputer)), 3, 2 = LT) Then
WSHNetwork.MapNetworkDrive "P:", "\\"&strComputer&"\Procede",True
else
WSHNetwork.MapNetworkDrive "P:", "\\prosperity\SharedData\CommonShare",True
End if
++++++++++++++++++++++++
I'm trying to use the naming convention of my computers to map this "P" drive. Are VBScripts not the solution for Logon scripts?

You help is appreciated!
Kelvin
 
Is that a direct cut & paste? You parentheses are wrong, (your evaluation is now inside the mid function) and LT is no long a string. Now that you've resolved the object reference with WSHNetwork, go back to your original if stmt. (mid(UCase(strComputer), 3, 2) = "LT")

VBScript is an excellent solution for login scripts.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
Why did you change that line from your original??

If (mid(UCase(strComputer), 3, 2) = "LT") Then
 
I wish I could say I had a good reason... I don't, sorry.
It works now!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top