Hi there, this should help with steps 1, 2, and 3. Step 4, however.....I'm not quite sure what you want to do with the default gateway.....but I have added a display of the IP address and gateway for you to look at.
Regards,
Rob.
' First we get the current screen resolution so we can place
' our progress window in the centre
' See: http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul05/hey0721.mspx
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select PelsWidth,PelsHeight From Win32_DisplayConfiguration")
For Each objItem in colItems
intScreenWidth = objItem.PelsWidth
intScreenHeight = objItem.PelsHeight
Next
' Now create our display window and position it in the centre
intWidth = 800
intHeight = 600
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
objIE.Toolbar = 0
objIE.StatusBar = 0
objIE.AddressBar = 0
objIE.MenuBar = 0
objIE.Width = intWidth
objIE.Height = intHeight
objIE.Resizable = 0
While objIE.ReadyState <> 4
WScript.Sleep 100
Wend
objIE.Left = (intScreenWidth / 2) - (intWidth / 2)
objIE.Top = (intScreenHeight / 2) - (intHeight / 2)
objIE.Visible = True
' Now run your normal code and you can use
' objIE.document.WriteLn "This is my message"
' anywhere in the code to update progress
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strCaption = objItem.Caption
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
strIPAddress = Join(objItem.IPAddress, ",")
If strDefaultIPGateway <> "" And strIPAddress <> "0.0.0.0" Then
objIE.Document.WriteLn "<BR>Your IP Address: " & strIPAddress & "<BR>Your gateway: " & strDefaultIPGateway & "<BR>"
End If
Next
objIE.Document.WriteLn "<BR><BR>Running logon scripts. Please wait..." & "<BR>"
On Error Resume Next
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName
boolErrorEncountered = False
objIE.Document.WriteLn "<BR>" & "Removing currently mapped network drives..."
'Disconnect any drive mappings as needed.
If objFSO.DriveExists("H:") = True Then WSHNetwork.RemoveNetworkDrive "H:", True, True
If objFSO.DriveExists("J:") = True Then WSHNetwork.RemoveNetworkDrive "J:", True, True
If objFSO.DriveExists("M:") = True Then WSHNetwork.RemoveNetworkDrive "M:", True, True
If objFSO.DriveExists("N:") = True Then WSHNetwork.RemoveNetworkDrive "N:", True, True
If objFSO.DriveExists("O:") = True Then WSHNetwork.RemoveNetworkDrive "O:", True, True
If objFSO.DriveExists("P:") = True Then WSHNetwork.RemoveNetworkDrive "P:", True, True
If objFSO.DriveExists("Q:") = True Then WSHNetwork.RemoveNetworkDrive "Q:", True, True
If objFSO.DriveExists("S:") = True Then WSHNetwork.RemoveNetworkDrive "S:", True, True
If objFSO.DriveExists("T:") = True Then WSHNetwork.RemoveNetworkDrive "T:", True, True
If objFSO.DriveExists("U:") = True Then WSHNetwork.RemoveNetworkDrive "U:", True, True
If Err.Number <> 0 Then
boolErrorEncountered = True
objIE.Document.WriteLn "<BR>" & "There was an error removing one or more network drives."
objIE.Document.WriteLn "<BR>" & Err.Number & ": " & Err.Description
Err.Clear
End If
'Give the PC time to do the disconnect, wait 200 milliseconds
WScript.sleep 200
'Map drives needed by all
objIE.Document.WriteLn "<BR>" & "Mapping shared drive S:"
WSHNetwork.MapNetworkDrive "S:", "\\Server\share",True
If Err.Number <> 0 Then
boolErrorEncountered = True
objIE.Document.WriteLn "<BR>" & "There was an error mapping to S: Drive."
objIE.Document.WriteLn "<BR>" & Err.Number & ": " & Err.Description
Err.Clear
End If
'Now check for group memberships and map appropriate drives
'Note that this checks Global Groups and not domain local groups.
objIE.Document.WriteLn "<BR>" & "Mapping group specific drives..."
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
Select Case UCase(GroupObj.Name)
'Check for group memberships and take needed action
'In this example below, ADMIN and WORKERB are groups.
'Note the use of all upper case letters as mentioned above.
'Note also that the groups must be Global Groups.
Case "Group1"
WSHNetwork.MapNetworkDrive "m:", "\\Server\share",True
Case "Group2"
WSHNetwork.MapNetworkDrive "h:", "\\Server\share",True
WSHNetwork.MapNetworkDrive "j:", "\\Server\share",True
WSHNetwork.MapNetworkDrive "m:", "\\Server\share",True
WSHNetwork.MapNetworkDrive "n:", "\\Server\share",True
WSHNetwork.MapNetworkDrive "o:", "\\Server\share",True
WSHNetwork.MapNetworkDrive "p:", "\\Server\share",True
End Select
Next
If Err.Number <> 0 Then
boolErrorEncountered = True
objIE.Document.WriteLn "<BR>" & "There was an error mapping one or more group specific drives."
objIE.Document.WriteLn "<BR>" & Err.Number & ": " & Err.Description
Err.Clear
End If
If boolErrorEncountered = False Then
objIE.Document.WriteLn "<BR><BR>" & "Logon script complete. This window will close in three seconds."
WScript.Sleep 3000
objIE.Quit
Set objIE = Nothing
Else
objIE.Document.WriteLn "<BR><BR>" & "Errors were encounterd. Please leave this window open and notify your system administrator."
End If
wscript.quit
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151:





by: tetran_auPosted on 2009-09-10 at 18:41:46ID: 25306103
hey guys i found this and did a bit extra but i keep getting a bunch of errors
Can you help me identify what i am missing or doing incorrectly
Select allOpen in new window