Guest User

Untitled

a guest
Nov 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. '===========================
  2. strServer = "abc.example.com"
  3. strUsername = InputBox("Enter the user name to access " & strServer, "Network Username", "username@domain")
  4. strPassword = InputBox("Enter the password for the user " & strUsername, "Network Password")
  5.  
  6. strCommand = "cmd /c cmdkey /add:" & strServer & " /user:" & strUsername & " /pass:" & strPassword
  7. Set objShell = CreateObject("WScript.Shell")
  8. objShell.Run strCommand, 0, True
  9.  
  10. MsgBox strUsername & " has been added to the credentials list."
  11.  
  12. Set objFSO = CreateObject("Scripting.FileSystemObject")
  13.  
  14. strSourceFile = "C:Desktoplocal_file.txt"
  15. strDestDir = "EBackup" 'Double backslash used to access network shares with UNC naming scheme.
  16. If Right(strDestDir, 1) <> "" Then
  17. strDestDir = strDestDir & ""
  18. End If
  19. If objFSO.FileExists(strSourceFile) Then
  20. If objFSO.FolderExists(strDestDir) Then
  21. objFSO.CopyFile strSourceFile, strDestDir, True
  22. Else
  23. MsgBox "Please check that the destination folder exists of:" & VbCrLf & strDestDir
  24. End If
  25. Else
  26. MsgBox "Please check that the source file exists of:" & VbCrLf & strSourceFile
  27. End If
  28.  
  29. strCommand = "cmd /c cmdkey /delete:" & strServer
  30. Set objShell = CreateObject("WScript.Shell")
  31. 'objShell.Run strCommand, 0, True
  32. '=======================
Add Comment
Please, Sign In to add comment