Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ON ERROR RESUME NEXT
- Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path, objNetwork, objNetwork1, objNetwork2, objnetwork3
- Dim CheckDrive, CheckDrive1, CheckDrive2, CheckDrive3, AlreadyConnected, AlreadyConnected1, AlreadyConnected2, AlreadyConnected3 intDrive
- Set WSHShell = CreateObject("WScript.Shell")
- Set WSHNetwork = CreateObject("WScript.Network")
- Set fso = CreateObject("Scripting.FileSystemObject")
- 'Automatically find the domain name
- Set objDomain = getObject("LDAP://rootDse")
- DomainString = objDomain.Get("dnsHostName")
- WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
- 'Grab the user name
- UserString = WSHNetwork.UserName
- 'Grab the computer name for use in add-on code later
- strComputer = WSHNetwork.ComputerName
- 'Disconnect ALL mapped drives
- Set clDrives = WshNetwork.EnumNetworkDrives
- For i = 0 to clDrives.Count -1 Step 2
- WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
- Next
- 'Give the PC time to do the disconnect, wait 300 milliseconds
- wscript.sleep 300
- Set objNetwork = WScript.CreateObject("WScript.Network")
- Set objNetwork1 = WScript.CreateObject("WScript.Network")
- Set objNetwork2 = WScript.CreateObject("WScript.Network")
- Set objNetwork3 = WScript.CreateObject("WScript.Network")
- strLocalDrive = "W:"
- strRemoteShare = "\\abzns02\Geores_UK"
- strLocalDrive1 = "X:"
- strRemoteShare1 = "\\abzns02\Geores_NORWAY"
- strLocalDrive2 = "Y:"
- strRemoteShare2 = "\\abzns02\Geores_MISC"
- strLocalDrive3 = "Z:"
- strRemoteShare3 = "\\abzns02\Geores_BD"
- Set objExplorer = WScript.CreateObject _
- ("InternetExplorer.Application", "IE_")
- objExplorer.Navigate "file:///C:\Documents and Settings\KJX\Desktop\password.htm"
- objExplorer.ToolBar = 0
- objExplorer.StatusBar = 0
- objExplorer.Width = 400
- objExplorer.Height = 180
- objExplorer.Left = 300
- objExplorer.Top = 200
- objExplorer.Visible = 1
- Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
- Wscript.Sleep 250
- Loop
- strUsername = objExplorer.Document.Body.All.UserName.Value
- strPassword = objExplorer.Document.Body.All.UserPassword.Value
- strButton = objExplorer.Document.Body.All.OKClicked.Value
- objExplorer.Quit
- Wscript.Sleep 250
- If strButton = "Cancelled" Then
- Wscript.Quit
- End If
- mDrive = "W:"
- mDrive1 = "X:"
- mDrive2 = "Y:"
- mDrive3 = "Z:"
- Set oShell = CreateObject("Shell.Application")
- oShell.NameSpace(mDrive).Self.Name = "Geores UK test"
- oShell.NameSpace(mDrive1).Self.Name = "Geores Norway test"
- oShell.NameSpace(mDrive2).Self.Name = "Geores MISC test"
- oShell.NameSpace(mDrive3).Self.Name = "Geores BD test"
- Set CheckDrive = objNetwork.EnumNetworkDrives()
- Set CheckDrive1 = objNetwork1.EnumNetworkDrives()
- Set CheckDrive2 = objNetwork2.EnumNetworkDrives()
- Set CheckDrive3 = objNetwork3.EnumNetworkDrives()
- AlreadyConnected = False
- For intDrive = 0 To CheckDrive.Count - 1 Step 2
- If CheckDrive.Item(intDrive) =strLocalDrive _
- Then AlreadyConnected =True
- intDrive = Nothing
- Next
- AlreadyConnected1 = False
- For intDrive = 0 To CheckDrive1.Count - 1 Step 2
- If CheckDrive1.Item(intDrive) =strLocalDrive1 _
- Then AlreadyConnected =True
- intDrive = Nothing
- Next
- AlreadyConnected2 = False
- For intDrive = 0 To CheckDrive2.Count - 1 Step 2
- If CheckDrive2.Item(intDrive) =strLocalDrive2 _
- Then AlreadyConnected =True
- intDrive = Nothing
- Next
- AlreadyConnected3 = False
- For intDrive = 0 To CheckDrive3.Count - 1 Step 2
- If CheckDrive2.Item(intDrive) =strLocalDrive2 _
- Then AlreadyConnected =True
- intDrive = Nothing
- Next
- If AlreadyConnected Then
- If AlreadyConnected1 Then
- If AlreadyConnected2 Then
- If AlreadyConnected3 Then
- wscript.echo "Credentials OK"
- Else
- wscript.echo "Credentials Bad"
- End If
- End If
- End If
- End If
- 'set UserObj = Nothing
- 'set GroupObj = Nothing
- 'set WSHNetwork = Nothing
- 'set DomainString = Nothing
- 'set WSHSHell = Nothing
- 'Set WSHPrinters = Nothing
- 'Set objNetwork = Nothing
- 'Set objNetwork1 = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement