Guest User

Untitled

a guest
Jan 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Sequentially execute tasks
  2. @echo off
  3. taskkill /t /im App.exe
  4. ping -n 5 127.0.0.1 > nul
  5. xcopy /y /r "C:Some pathMy File.ext" "C:App path"
  6. Del /f /q "C:App pathApp sub-directory*.*"
  7.  
  8. @echo off
  9.  
  10. setlocal EnableDelayedExpansion
  11.  
  12. for /f "tokens=2" %%p in ('tasklist /fi "imagename eq App.exe" /fo list ^| find "PID:"') do set pid=%%p
  13.  
  14. taskkill /t /pid %pid%
  15.  
  16. :wait
  17. ping -n 2 127.0.0.1 >nul
  18. tasklist /fi "pid eq %pid%" /fo list | find "PID:"
  19. if %errorlevel% equ 0 goto wait
  20.  
  21. xcopy /y /r "C:Some pathMy File.ext" "C:App path"
  22. del /f /q "C:App pathApp sub-directory*.*"
  23.  
  24. endlocal
  25.  
  26. Set wmi = GetObject("winmgmts://./root/cimv2")
  27. query = "SELECT * FROM Win32_Process WHERE Name = 'App.exe'"
  28.  
  29. For Each p In wmi.ExecQuery(query)
  30. p.Terminate
  31. Next
  32.  
  33. Do While wmi.ExecQuery(query).Count > 0
  34. WScript.Sleep 100
  35. Loop
  36.  
  37. Set fso = CreateObject("Scripting.FileSystemObject")
  38. If fso.FileExists("C:App pathMy File.ext") Then
  39. fso.DeleteFile "C:App pathMy File.ext", True
  40. End If
  41. fso.CopyFile "C:Some pathMy File.ext", "C:App path", True
  42. fso.DeleteFile "C:App pathApp sub-directory*.*", True
  43.  
  44. Set f = fso.GetFile("C:App pathMy File.ext")
  45. f.Attributes = f.Attributes And Not 1
Add Comment
Please, Sign In to add comment