Advertisement
Guest User

Rtf

a guest
May 12th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. Option Explicit
  2. On Error Resume Next
  3. Dim objNetwork, objShell, objShell1, clDrives, i
  4. Dim strUser, strPassword, strProfile, strUserWithDomain
  5. Dim strServer1, strServer2, strUserDomain, strCommand1, strCommand2
  6. Dim strDriveLetter1, strRemotePath1, strNewName1
  7.  
  8. Function textInput( myPrompt )
  9. If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
  10. WScript.StdOut.Write myPrompt & " "
  11. textInput = WScript.StdIn.ReadLine
  12. Else
  13. textInput = InputBox( myPrompt )
  14. End If
  15. End Function
  16. strServer1 = "192.168.2.231"
  17.  
  18.  
  19. strUser = textInput( "Nazwa użytkownika:" )
  20. strPassword = textInput( "Hasło:" )
  21. 'WScript.Echo "U¿ytkownik: " & strUser & " hasło " & strPassword
  22. strProfile = "false"
  23.  
  24. strDriveLetter1 = "S:"
  25. strRemotePath1 = "\\" & strServer1 & "\" & strUser
  26. strNewName1 = "DyskUcznia"
  27.  
  28.  
  29.  
  30. Set objNetwork = WScript.CreateObject("WScript.Network")
  31. strUserDomain = objNetwork.UserDomain
  32. 'Wscript.Echo strUserDomain
  33.  
  34. strUserWithdomain = strUserDomain & "\" & strUser
  35.  
  36.  
  37. Set clDrives = objNetwork.EnumNetworkDrives
  38. For i = 0 to clDrives.Count -1 Step 2
  39. objNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
  40. Next
  41.  
  42. WScript.sleep 300
  43.  
  44. 'Set objShell = CreateObject("WScript.Shell")
  45. 'objShell.Run strCommand1, 0, True
  46. 'objShell.Run strCommand2, 0, True
  47.  
  48. objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile, strUserWithDomain , strPassword
  49.  
  50. Set objShell1 = CreateObject("Shell.Application")
  51. objShell1.NameSpace(strDriveLetter1).Self.Name = strNewName1
  52.  
  53. if Err.Number <> 0 then
  54. Err.Raise 6 ' Raise an overflow error.
  55. 'WScript.Echo "Error # " & CStr(Err.Number) & " " & Err.Description
  56. WScript.Echo " Wpisz poprawnie Użytkownika i Hasło - dysk nie został podłączony!! "
  57. else
  58. WScript.Echo "Zamapowalem dyski "
  59. end if
  60. Err.Clear
  61. WScript.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement