Login | |
|
 |
Network drive mapping - 4/13/2006 3:30:30 AM
|
|
 |
|
| |
BeginR_script1
Posts: 3
Score: 0
Joined: 4/3/2006
Status: offline
|
Hello everyone: I found this script and have been working on it for few weeks now. The script is working fine and it maps the only network drive (U) which I want but once it maps the drive it give an error on line 69. I am not an expert in wsh and vbscript, only a beginner. I would really appreciat eif anyone can help me out. Thanks *************************************************************************************************************************** Dim strComputerName Dim strUserName Dim strDomainName Set wshNetwork = WScript.CreateObject( "WScript.Network" ) do while wshNetwork.username = "" WScript.Sleep 250 loop strComputerName = wshNetwork.computerName strUserName = wshNetwork.userName strDomainName = wshNetwork.userDomain call subDriveMap ' ******************************************************************************** ' * ' * Group Information ' * Sub subDriveMap() Dim colNetDrives Dim strLocal Dim strRemote Dim strLocalSets Dim bForce Dim bUpdateProfile bForce = true bUpdateProfile = true ' Set a variable for a script file to map user specific drives. strLocalSets = "J:\local.vbs" ' Query the ADSI object to get User Information. Set up the home drive variables. adspath = "WinNT://" & strDomainName & "/" & strUserName set adsobj = getobject( adspath ) strHomeDrive = adsobj.homeDirDrive strHomeDir = adsobj.homeDirectory ' Setup objects to map network drives. Set wshNetwork = WScript.CreateObject( "WScript.Network" ) Set wshShell = WScript.CreateObject("WScript.Shell" ) Set colNetDrives = wshNetwork.EnumNetworkDrives ' Remove any drive mappings. This removes all drive mappings that might be set using ' reconnect at logon. If colNetDrives.Count = 0 then ' MsgBox "There are no drive mappings at this time." Else For x = 0 to colNetDrives.count-1 Step 2 wshNetwork.RemoveNetworkDrive colNetDrives.Item(x), bForce, bUpdateProfile Next End If ' Map Users Home Drive wshNetwork.MapNetworkDrive strHomeDrive, strHomeDir ' Map Any Global Drives wshNetwork.MapNetworkDrive "u:", "\\myServerName\myShare" ' Map all Group Specific Drives for each prop in adsobj.groups select case UCASE(prop.name) case "myDomainGlobalGroup1" wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept1" case "myDomainGlobalGroup2" wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept2" case else wshNetwork.MapNetworkDrive "G:", "\\myServerName\otherDepts" end select next ' Check to see if a User Script Exists and run it. Set fso = CreateObject("Scripting.FileSystemObject") IF fso.FileExists(strLocalSets) then ' MsgBox "Local Settings File on the User's Home Drive" WshShell.Run strLocalSets, 2, TRUE End If ' * ' * This routine when uncommented will display the mapped drives ' * Set colNetDrives = wshNetwork.EnumNetworkDrives Wscript.Echo colNetDrives.Count If colNetDrives.Count = 0 then msgBox "There are no drive mappings at this time." Else For x = 0 to colNetDrives.count-1 Step 2 strMsg = strMsg & colNetDrives.Item(x) & chr(9) & colNetDrives.Item(x+1) & vbCRLF Next msgBox strMsg End If End Sub
|
|
| |
|
|
|
 |
RE: Network drive mapping - 4/18/2006 4:47:22 AM
|
|
 |
|
| |
ebgreen
Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
|
You still have not told us exactly which line is 69, but judging from the error I'd say that your path is invalid or you do not have permission to map to that path.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|