Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Dim objShell
  4. Dim objFSO
  5. Dim objFile
  6. Dim strRemoteFile
  7. Dim strCentralRepository
  8. Dim strCmd03
  9. Dim objArgs, strSourceComputer, strDestinationComputer, intArg
  10. Dim strToSplit, strSplitted, strSplitElement, myArray
  11. dim error, error1
  12.  
  13. Set objFSO = CreateObject("Scripting.FileSystemObject")
  14. Set objShell = WScript.CreateObject("WScript.Shell")
  15. Set objFile = objFSO.OpenTextFile("C:\USMTScript\loadstatemachines.txt")
  16.  
  17. strCentralRepository = "\\192.168.1.120\USMTScript\USMTCentralRepository"
  18.  
  19. Do Until objFile.AtEndOfStream
  20. redim myArray(2)
  21. myArray = split(objFile.Readline,",")
  22. strSourceComputer = UCase(myArray(0))
  23. strDestinationComputer = UCase(myArray(1))
  24. wscript.echo "The source PC is " & strSourceComputer & " and " & "the destination PC is " & strDestinationComputer
  25. call RunLoadstate(strSourceComputer, strDestinationComputer)
  26. loop
  27.  
  28. objFile.close
  29. Set objFSO = Nothing
  30. Set objShell = Nothing
  31. Set objFile = Nothing
  32.  
  33. sub RunLoadstate(strSourceComputer, strDestinationComputer )
  34. If objFSO.FileExists(strCentralRepository & "\" & strSourceComputer & "\USMT\USMT.MIG" ) Then
  35. msgbox("The File Exists, we will move on with checking the second"
  36. strRemoteFile = "\\" & strDestinationComputer & "\C$\USMTLocalLoadstate.vbs"
  37. objFSO.CopyFile "C:\USMTScript\USMTLocalLoadstate.vbs", strRemoteFile, TRUE
  38. If objFSO.FileExists(strRemoteFile) Then
  39. msgbox("The File Exists Again! this means there will be no errors")
  40. objShell.Run "psexec \\" & strDestinationComputer & " -s cmd /c " & chr(34) & "cscript.exe c:\USMTLocalLoadstate.vbs" & " " & strSourceComputer & chr(34)
  41.  
  42. Else
  43. msgbox("file " & strRemoteFile.tostring & " Does not exists! this is technically the 2nd error")
  44. wscript.sleep 6000
  45. error1 = MsgBox("Check " & strDestinationComputer & " is online",16,"Error")
  46. document.write(error1)
  47. End if
  48.  
  49.  
  50. Else
  51. msgbox("The original file does not exist, this is the first if statement error")
  52. wscript.sleep 6000
  53. error = MsgBox("Unable to find the USMT MIG file for " & strSourceComputer,16,"Error")
  54. document.write(error)
  55. End If
  56.  
  57.  
  58.  
  59.  
  60. end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement