Re: Login script mapped drvs show up disconnected

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Chris Jones (cka691_at_alltel.net)
Date: 02/01/05


Date: Tue, 1 Feb 2005 11:53:47 -0500

I think there is a problem with net use if drives are already mapped or
connected, I use a script here are the entries.... Try this and tell me how
it works, you can create this script with notepad, name it something.vbs,
then call on it with login bat file in Sysvol folder.

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()

DriveLetter = "Z:" 'must be capitalized
RemotePath = "\\Svr01\SEALS"

AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next

If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."

Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp "Drive " & DriveLetter & " disconnected."
End if

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()

DriveLetter = "X:" 'must be capitalized
RemotePath = "\\Svr01\inactive"

AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter Then AlreadyConnected = True
Next

If AlreadyConnected = False then
WShNetwork.MapNetworkDrive DriveLetter, RemotePath
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."

Else
WShNetwork.RemoveNetworkDrive DriveLetter
WshShell.PopUp "Drive " & DriveLetter & " disconnected."
End if



Relevant Pages

  • Re: Help on script
    ... Try this I would email the script to you, but being you dont know me you ... WShNetwork.MapNetworkDrive DriveLetter, RemotePath ... > but the drives are mapped up. ...
    (microsoft.public.windows.server.sbs)
  • Re: Reading cells from Excel
    ... ObjNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile and the ... script now maps the drives in one run. ... 'Define whether the map info should be removed from the current user's ...
    (microsoft.public.vb.syntax)
  • To Scan all computers in network and copy a file and paste it to fileserver(shared space)
    ... hi i have a script that will copy a file from one location and paste it ... strUsername = objnetwork.username ... If CheckDrive.Item= DriveLetter Then ... objNetwork.MapNetworkDrive DriveLetter, RemotePath ...
    (microsoft.public.windows.server.scripting)
  • Re: Reading cells from Excel
    ... guess I've never mapped more than about 3 drives in a logon script before. ... ObjNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile ...
    (microsoft.public.vb.syntax)
  • Re: To Scan all computers in network and copy a file and paste it to fileserver(shared space)
    ... strUsername = objnetwork.username ... If CheckDrive.Item= DriveLetter Then ... objNetwork.MapNetworkDrive DriveLetter, RemotePath ... i want to modify this script to be ...
    (microsoft.public.windows.server.scripting)