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!

Parameter error on logon script 1

Status
Not open for further replies.

Hondy

Technical User
Mar 3, 2003
864
GB
offending (partial) script below:

I have a logon script which checks for existing drives, removes them and puts new maps in.

The problem is that the logon script falls over when the automatically connecting mappings like \\server\sysvol don't have a letter and therefore the script can't continue.

if you manually remove them using net use \\server\sysvol /delete then the script runs fine. But, when you put the script into the sysvol share, as soon as you logon the sysvol connection comes back and the script falls over again!!

In short, if you do NET USE and can see a connection without a drive letter (e.g. My Network Places) the script won't work.

What do I need to do??

Thanks

' *********************************** Map drive function *****

Function MapDrive(Drive, FileServer, Share, Tree)

If oFSO.DriveExists(FileServer & Share) = True Then

oNet.MapNetworkDrive Drive, FileServer & Share & Tree

Else
Wscript.Echo("Cannot Map " & Drive & " to " & FileServer & Share)
End If

End Function

' *********************************** Enumerate drives for removal prior to mapping *****

Set oDrives = oNet.EnumNetworkDrives

For i = 0 to oDrives.Count - 1 Step 2
WshShell.Popup "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1) & VBCRLF & " is currently already mapped.", 2, "Caution"
deldrive = oDrives.Item(i)
oNet.RemoveNetworkDrive deldrive
Next
 
I don't see where your MapDrive is called. And what line does this script fail on?

I can't seem to reproduce this problem.
 
Thanks for reading.

The script is too long to post, there is nothing wrong with the script as it stands, it's just that it can't cope with UNC mappings.

The part of script that I have posted is the part which shows you how it deals with drives that are already mapped such as G:

The problem is (windows) \\server\sysvol for example doesn't actually map to a drive letter, it just creates a UNC connection to this logon share (sysvol being the standard windows logon share). So the script finds a mapping with no letter and fails when the script tries to removedrive.

I was looking for a way of either error trapping this or removing these UNC shares via script (VBS)

Thanks
 
Change

deldrive = oDrives.Item(i)

to

If oDrives.Item(i)="" Then
delDrive = oDrives.Item(i+1)
Else
delDrive = oDrives.Item(i)
End If

Jon Hawkins
 
Thanks, that's great that's fixed it :)
(I'm not a programmer, just IT support)

If you can think of a way to disconnect open files that would be perfect, otherwise thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top