I need to gracefully terminate (either via .bat or .vbs) a specific app in order to safely overwrite a (read-only) file in its directory and then delete all files in one of its sub-directories.
I had something like this in mind:
@echo off
taskkill /t /im App.exe
ping -n 5 127.0.0.1 > nul
xcopy /y /r "C:\Some path\My File.ext" "C:\App path"
Del /f /q "C:\App path\App sub-directory\*.*"
Rather than waiting a fixed amount of time (5 seconds in the above example) I would like the 2 last commands to be executed only when the taskkill is complete (i.e. the app is closed after eventual prompts have been resolved by the user).
Is there a way to do that?
In batch you could do it like this:
I’d prefer VBScript for this, though.
Instead of deleting the destination file, you could also remove the read-only flag: