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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript with a IPC$ Share help needed

Status
Not open for further replies.

cajuntank

IS-IT--Management
May 20, 2003
947
US
Downloaded since I suck as scripting and like GUI(s). I have one issue where a vendor installed their application via a hidden IPC share, so \\server\app$

This is for a specific group and here's what the GUI gave me

ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")

'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName

'Map drives needed by all users
WSHNetwork.RemoveNetworkDrive "M:", True, True
WSHNetwork.MapNetworkDrive "M:", "\\co-fs1\Departments",True
WSHNetwork.RemoveNetworkDrive "U:", True, True
WSHNetwork.MapNetworkDrive "U:", "\\co-fs1\" & UserString,True

'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
Case "CENTRAL OFFICE"
WSHNetwork.RemoveNetworkDrive "O:", True, True
WSHNetwork.MapNetworkDrive "O:", "\\co-fs1\Apps", True
Case "FOOD SERVICE"
WSHNetwork.RemoveNetworkDrive "X:", True, True
WSHNetwork.MapNetworkDrive "X:", "\\lunch-fs1\horizon$", True
End Select
Next
End Select
Next

'Synchronise PC's time with server
WSHShell.Run "net time /domain:" & DomainString & " /set /yes", 0, TRUE

'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing

'Quit the Script
Wscript.Quit

With it this way, I get a scripting error at login. How would I fix this?

Thanks.
 
There are two sets of "Next" and "End Select". Take out one set. Also "\\co-fs1\Apps", and you said hidden (Apps$).
 
I used "\\server\app$" in the question just as a reference before expounding on the specific in the actual script.
So the actual drive mapping would be
WSHNetwork.MapNetworkDrive "X:", "\\lunch-fs1\horizon$", True
 
So your script is correct, no error then. Is that what you mean?
 
I get an error in my script due to the IPC Share, when I take the line:
WSHNetwork.MapNetworkDrive "X:", "\\lunch-fs1\horizon$", True
out, it works fine. It's something to do with the $ part.
 
Why not posting the whole error message ????

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top