Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Network drive mapping

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,33487
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Network drive mapping
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 RE: Network drive mapping - 4/14/2006 4:55:55 AM   
  esnmb

 

Posts: 448
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Not sure what line is 69.  If I copy the whole script to y editor I see line 69 as nothing.  Can you mark the line with the error?

(in reply to BeginR_script1)
 
 
Post #: 2
 
 RE: Network drive mapping - 4/17/2006 1:27:34 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
Also, please tell us what the error is.

_____________________________

"... 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

(in reply to esnmb)
 
 
Post #: 3
 
 RE: Network drive mapping - 4/18/2006 4:43:02 AM   
  BeginR_script1

 

Posts: 3
Score: 0
Joined: 4/3/2006
Status: offline
Sorry, I was in a process of changing my ISP and all hell broke lose. Anyway, I am back here is the error message:

Line: 69
Char:5
Error: The Network path was not found
Code: 80070035
Source; WSHNetwork.MapNetworkDrive


(in reply to BeginR_script1)
 
 
Post #: 4
 
 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

(in reply to BeginR_script1)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Network drive mapping Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts