Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. ON ERROR RESUME NEXT
  2.  
  3. Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path, objNetwork, objNetwork1, objNetwork2, objnetwork3
  4. Dim CheckDrive, CheckDrive1, CheckDrive2, CheckDrive3, AlreadyConnected, AlreadyConnected1, AlreadyConnected2, AlreadyConnected3 intDrive
  5.  
  6. Set WSHShell = CreateObject("WScript.Shell")
  7. Set WSHNetwork = CreateObject("WScript.Network")
  8. Set fso = CreateObject("Scripting.FileSystemObject")
  9. 'Automatically find the domain name
  10. Set objDomain = getObject("LDAP://rootDse")
  11. DomainString = objDomain.Get("dnsHostName")
  12. WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
  13.  
  14. 'Grab the user name
  15. UserString = WSHNetwork.UserName
  16.  
  17. 'Grab the computer name for use in add-on code later
  18. strComputer = WSHNetwork.ComputerName
  19.  
  20. 'Disconnect ALL mapped drives
  21. Set clDrives = WshNetwork.EnumNetworkDrives
  22. For i = 0 to clDrives.Count -1 Step 2
  23. WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
  24. Next
  25.  
  26. 'Give the PC time to do the disconnect, wait 300 milliseconds
  27. wscript.sleep 300
  28.  
  29. Set objNetwork = WScript.CreateObject("WScript.Network")
  30. Set objNetwork1 = WScript.CreateObject("WScript.Network")
  31. Set objNetwork2 = WScript.CreateObject("WScript.Network")
  32. Set objNetwork3 = WScript.CreateObject("WScript.Network")
  33.  
  34. strLocalDrive = "W:"
  35. strRemoteShare = "\\abzns02\Geores_UK"
  36.  
  37. strLocalDrive1 = "X:"
  38. strRemoteShare1 = "\\abzns02\Geores_NORWAY"
  39.  
  40. strLocalDrive2 = "Y:"
  41. strRemoteShare2 = "\\abzns02\Geores_MISC"
  42.  
  43. strLocalDrive3 = "Z:"
  44. strRemoteShare3 = "\\abzns02\Geores_BD"
  45.  
  46. Set objExplorer = WScript.CreateObject _
  47. ("InternetExplorer.Application", "IE_")
  48.  
  49. objExplorer.Navigate "file:///C:\Documents and Settings\KJX\Desktop\password.htm"
  50. objExplorer.ToolBar = 0
  51. objExplorer.StatusBar = 0
  52. objExplorer.Width = 400
  53. objExplorer.Height = 180
  54. objExplorer.Left = 300
  55. objExplorer.Top = 200
  56. objExplorer.Visible = 1
  57.  
  58. Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
  59. Wscript.Sleep 250
  60. Loop
  61.  
  62. strUsername = objExplorer.Document.Body.All.UserName.Value
  63. strPassword = objExplorer.Document.Body.All.UserPassword.Value
  64. strButton = objExplorer.Document.Body.All.OKClicked.Value
  65. objExplorer.Quit
  66. Wscript.Sleep 250
  67.  
  68. If strButton = "Cancelled" Then
  69. Wscript.Quit
  70. End If
  71.  
  72. mDrive = "W:"
  73. mDrive1 = "X:"
  74. mDrive2 = "Y:"
  75. mDrive3 = "Z:"
  76.  
  77. Set oShell = CreateObject("Shell.Application")
  78.  
  79. oShell.NameSpace(mDrive).Self.Name = "Geores UK test"
  80. oShell.NameSpace(mDrive1).Self.Name = "Geores Norway test"
  81. oShell.NameSpace(mDrive2).Self.Name = "Geores MISC test"
  82. oShell.NameSpace(mDrive3).Self.Name = "Geores BD test"
  83.  
  84. Set CheckDrive = objNetwork.EnumNetworkDrives()
  85. Set CheckDrive1 = objNetwork1.EnumNetworkDrives()
  86. Set CheckDrive2 = objNetwork2.EnumNetworkDrives()
  87. Set CheckDrive3 = objNetwork3.EnumNetworkDrives()
  88.  
  89. AlreadyConnected = False
  90. For intDrive = 0 To CheckDrive.Count - 1 Step 2
  91. If CheckDrive.Item(intDrive) =strLocalDrive _
  92. Then AlreadyConnected =True
  93. intDrive = Nothing
  94. Next
  95.  
  96. AlreadyConnected1 = False
  97. For intDrive = 0 To CheckDrive1.Count - 1 Step 2
  98. If CheckDrive1.Item(intDrive) =strLocalDrive1 _
  99. Then AlreadyConnected =True
  100. intDrive = Nothing
  101. Next
  102.  
  103. AlreadyConnected2 = False
  104. For intDrive = 0 To CheckDrive2.Count - 1 Step 2
  105. If CheckDrive2.Item(intDrive) =strLocalDrive2 _
  106. Then AlreadyConnected =True
  107. intDrive = Nothing
  108. Next
  109.  
  110. AlreadyConnected3 = False
  111. For intDrive = 0 To CheckDrive3.Count - 1 Step 2
  112. If CheckDrive2.Item(intDrive) =strLocalDrive2 _
  113. Then AlreadyConnected =True
  114. intDrive = Nothing
  115. Next
  116.  
  117. If AlreadyConnected Then
  118. If AlreadyConnected1 Then
  119. If AlreadyConnected2 Then
  120. If AlreadyConnected3 Then
  121. wscript.echo "Credentials OK"
  122. Else
  123. wscript.echo "Credentials Bad"
  124. End If
  125. End If
  126. End If
  127. End If
  128.  
  129. 'set UserObj = Nothing
  130. 'set GroupObj = Nothing
  131. 'set WSHNetwork = Nothing
  132. 'set DomainString = Nothing
  133. 'set WSHSHell = Nothing
  134. 'Set WSHPrinters = Nothing
  135. 'Set objNetwork = Nothing
  136. 'Set objNetwork1 = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement