|
|
![]() |
|
|
Top | #1 |
|
OSNN Junior Addict
Joined: November 2011
Posts: 2
Reputation: 0
Power: 0 |
Code:
Dim strComputer,strIPAddress,strIPRange
Dim objNetwork
Dim IPConfigSet, IPConfig
Dim arrIPAddress
strComputer = "."
Set IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" _
& strComputer & "/root/cimv2").ExecQuery("select IPAddress from " _
& "Win32_NetworkAdapterConfiguration where IPEnabled=True")
Set objNetwork = WScript.CreateObject("WScript.Network")
For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
arrIPAddress = split(IPConfig.IPAddress(0) ,".")
strIPRange = arrIPAddress(0) & "." & arrIPAddress(1) & "." & arrIPAddress(2) & ".0"
select case strIPRange
case "172.31.2.*"
WshNetwork.RemoveNetworkDrive "G:"
WshNetwork.MapNetworkDrive "G:", "\\Server\Folder"
objNetwork.AddWindowsPrinterConnection "\\Server\Printer"(UPSTAIRS)"
case "172.31.1.*"
WshNetwork.RemoveNetworkDrive "G:"
WshNetwork.MapNetworkDrive "G:", "\\Server\Folder"
objNetwork.AddWindowsPrinterConnection "\\Server\Printer"
end select
end if
next
set objNetwork = nothing
set IPConfigSet = nothing
Any help would be great, this is getting stressful because this is one of the first scripts i need to run via vbs rather than just batch and i never really learned vbs Thanks!!!!!
|
|
|
|
|
|
Top | #2 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168 |
Assuming it's an Active Directory environment and you've setup your sites correctly, it shouldn't matter if they have laptops as wherever the computer is, it will pick up the correct AD site and you should be able to map drives based on site.
That all being said, does the script work if you run it manually? The code you wrote has you setting the strIPRange variable to xxx.xxx.xxx.0 but your case statement has you searching on xxx.xxx.xxx.* - it will never find a match that way. Code:
strIPRange = arrIPAddress(0) & "." & arrIPAddress(1) & "." & arrIPAddress(2) & ".0" select case strIPRange case "172.31.2.*" case "172.31.1.*" end select |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Possible Script? | omg its nlm | Web Design & Coding | 10 | February 9th, 2004 8:26am |
| log in script | gerrieb | Windows Desktop Systems | 1 | October 3rd, 2003 7:54am |
| Very new to PHP Script | Alex_is_Axel | Web Design & Coding | 17 | May 22nd, 2003 10:29pm |
| tv script | slmatix | Green Room | 13 | May 18th, 2003 5:42am |
| XP and script | ericha | Windows Desktop Systems | 6 | April 16th, 2002 5:41pm |