Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sequentially execute tasks
- @echo off
- taskkill /t /im App.exe
- ping -n 5 127.0.0.1 > nul
- xcopy /y /r "C:Some pathMy File.ext" "C:App path"
- Del /f /q "C:App pathApp sub-directory*.*"
- @echo off
- setlocal EnableDelayedExpansion
- for /f "tokens=2" %%p in ('tasklist /fi "imagename eq App.exe" /fo list ^| find "PID:"') do set pid=%%p
- taskkill /t /pid %pid%
- :wait
- ping -n 2 127.0.0.1 >nul
- tasklist /fi "pid eq %pid%" /fo list | find "PID:"
- if %errorlevel% equ 0 goto wait
- xcopy /y /r "C:Some pathMy File.ext" "C:App path"
- del /f /q "C:App pathApp sub-directory*.*"
- endlocal
- Set wmi = GetObject("winmgmts://./root/cimv2")
- query = "SELECT * FROM Win32_Process WHERE Name = 'App.exe'"
- For Each p In wmi.ExecQuery(query)
- p.Terminate
- Next
- Do While wmi.ExecQuery(query).Count > 0
- WScript.Sleep 100
- Loop
- Set fso = CreateObject("Scripting.FileSystemObject")
- If fso.FileExists("C:App pathMy File.ext") Then
- fso.DeleteFile "C:App pathMy File.ext", True
- End If
- fso.CopyFile "C:Some pathMy File.ext", "C:App path", True
- fso.DeleteFile "C:App pathApp sub-directory*.*", True
- Set f = fso.GetFile("C:App pathMy File.ext")
- f.Attributes = f.Attributes And Not 1
Add Comment
Please, Sign In to add comment