Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- On Error Resume Next
- Dim objNetwork, objShell, objShell1, clDrives, i
- Dim strUser, strPassword, strProfile, strUserWithDomain
- Dim strServer1, strServer2, strUserDomain, strCommand1, strCommand2
- Dim strDriveLetter1, strRemotePath1, strNewName1
- Function textInput( myPrompt )
- If UCase( Right( WScript.FullName, 12 ) ) = "\CSCRIPT.EXE" Then
- WScript.StdOut.Write myPrompt & " "
- textInput = WScript.StdIn.ReadLine
- Else
- textInput = InputBox( myPrompt )
- End If
- End Function
- strServer1 = "192.168.2.231"
- strUser = textInput( "Nazwa użytkownika:" )
- strPassword = textInput( "Hasło:" )
- 'WScript.Echo "U¿ytkownik: " & strUser & " hasło " & strPassword
- strProfile = "false"
- strDriveLetter1 = "S:"
- strRemotePath1 = "\\" & strServer1 & "\" & strUser
- strNewName1 = "DyskUcznia"
- Set objNetwork = WScript.CreateObject("WScript.Network")
- strUserDomain = objNetwork.UserDomain
- 'Wscript.Echo strUserDomain
- strUserWithdomain = strUserDomain & "\" & strUser
- Set clDrives = objNetwork.EnumNetworkDrives
- For i = 0 to clDrives.Count -1 Step 2
- objNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
- Next
- WScript.sleep 300
- 'Set objShell = CreateObject("WScript.Shell")
- 'objShell.Run strCommand1, 0, True
- 'objShell.Run strCommand2, 0, True
- objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile, strUserWithDomain , strPassword
- Set objShell1 = CreateObject("Shell.Application")
- objShell1.NameSpace(strDriveLetter1).Self.Name = strNewName1
- if Err.Number <> 0 then
- Err.Raise 6 ' Raise an overflow error.
- 'WScript.Echo "Error # " & CStr(Err.Number) & " " & Err.Description
- WScript.Echo " Wpisz poprawnie Użytkownika i Hasło - dysk nie został podłączony!! "
- else
- WScript.Echo "Zamapowalem dyski "
- end if
- Err.Clear
- WScript.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement