Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


800A0009 - Vista only- Mapping Network Drives

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> 800A0009 - Vista only- Mapping Network Drives
  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 >>
 800A0009 - Vista only- Mapping Network Drives - 8/13/2007 7:35:05 PM   
  SrotBULL

 

Posts: 1
Score: 0
Joined: 8/13/2007
Status: offline
Hi,

Joined just recently, and very new to scripting.

I am trying to create a login script to map network drives according to the IP Address of a workstation.

==============================================================
Option Explicit
Dim objNetwork, colDrives, DriveItem, strSave2Profile, strComputer, objWMIService
Dim colNetAdapters, objNetAdapter, strAddress
Dim arrOctets

strSave2Profile = "false"
strComputer = "."

Set objNetwork = WScript.CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled=True")

For DriveItem = 0 to colDrives.Count-1 Step 2
   objNetwork.RemoveNetworkDrive colDrives.Item(DriveItem)
Next

For Each objNetAdapter in colNetAdapters
    For Each strAddress in objNetAdapter.IPAddress
        arrOctets = Split(strAddress, ".")
        If arrOctets(0) = "128" and arrOctets(1) = "231" and arrOctets(2) = "72" Then
             WScript.Echo "Your in Segment 72."
             objNetwork.MapNetworkDrive "G:", "\\Server1\Share1"
             objNetwork.MapNetworkDrive "H:", "\\Server1\Share2"
             objNetwork.MapNetworkDrive "I:", "\\Server1\Share3"
             objNetwork.MapNetworkDrive "J:", "\\Server1\Share4"
             objNetwork.MapNetworkDrive "K:", "\\Server1\Share5"
             objNetwork.MapNetworkDrive "V:", "\\Server1\Share6"
             objNetwork.MapNetworkDrive "W:", "\\Server1\Share7"
             objNetwork.MapNetworkDrive "Y:", "\\Server1\Share8"
             objNetwork.MapNetworkDrive "Z:", "\\Server1\Share9", strSave2Profile, "Us5Name", "PS5Word"
             objNetwork.MapNetworkDrive "O:", "\\Server1\Share10"
        End If
        If arrOctets(0) = "128" and arrOctets(1) = "231" and arrOctets(2) = "74" Then
             WScript.Echo "Your in Segment 74."
             objNetwork.MapNetworkDrive "G:", "\\Server2\Share1"
             'objNetwork.MapNetworkDrive "H:", "\\Server2\Share2"
             'objNetwork.MapNetworkDrive "I:", "\\Server2\Share3"
             objNetwork.MapNetworkDrive "J:", "\\Server2\Share4"
             objNetwork.MapNetworkDrive "K:", "\\Server2\Share5"
             objNetwork.MapNetworkDrive "V:", "\\Server2\Share6"
             objNetwork.MapNetworkDrive "W:", "\\Server2\Share7"
             'objNetwork.MapNetworkDrive "Y:", "\\Server2\Share8"
             'objNetwork.MapNetworkDrive "Z:", "\\Server2\Share9", strSave2Profile, "Us5Name", "PS5Word"
             objNetwork.MapNetworkDrive "O:", "\\Server2\Share10"
        End If
        If arrOctets(0) = "128" and arrOctets(1) = "231" and arrOctets(2) = "75" Then
             WScript.Echo "Your in Segment 75."
             objNetwork.MapNetworkDrive "G:", "\\Server3\Share1"
             objNetwork.MapNetworkDrive "H:", "\\Server3\Share2"
             objNetwork.MapNetworkDrive "I:", "\\Server3\Share3"
             objNetwork.MapNetworkDrive "J:", "\\Server3\Share4"
             'objNetwork.MapNetworkDrive "Y:", "\\Server3\Share5"
             'objNetwork.MapNetworkDrive "Z:", "\\Server3\Share9", strSave2Profile, "Us5Name", "PS5Word"
             objNetwork.MapNetworkDrive "O:", "\\Server3\Share10"
       End If
   Next
Next
WScript.Quit
==============================================================

When I run the above script in a Windows XP Professional or a Windows 2003 Server machine, it works!

When I run the above script in my Windows Vista Enterprise machine, the following comes up.
---------------------------------------------------------
Script: C:\\MyScript
Line: 21
Char: 10
Error: Subscript out of range: '[Number: 1]'
Code: 800A0009
Source: Microsoft VBScript runtime error
--------------------------------------------------------

Althought, the above comes up all my drives are mapped.

I thought that I have not properly declared my array so,
I tried to change line 3 to "Dim arrOctets()", after this the following comes up in both my XP and Vista machines.
---------------------------------------------------------
Script: C:\\MyScript
Line: 20
Char: 10
Error: Type mismatch
Code: 800A000D
Source: Microsoft VBScript runtime error
--------------------------------------------------------
clicking "OK" does not map the drives...

As I have mentioned, I am very new to scripting...
I have been reading in the Internet on VBScript and found some scripts that I pieced together and the result is the above.

Would really appreciate if anyone can look through the above script and provide feedback.

Thank you in advance.

SB
 
 
Post #: 1
 
 
 
  

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 >> 800A0009 - Vista only- Mapping Network Drives 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