I am trying to use this to kill a running process, then delete the exe which runs that process and after that rename a file (.temp) with the same name as the deleted file and finally run it. However, I am having two problems: first one is that I am required to run this as administrator in order to be able to kill the task (I have solved this already running cmd as admin), and the second problem is that when rename is executed it says that the file already exists (but it should not because there was a delete just before). The code runs fine if you are not running the exe you want to kill, but if it is running then the said error appears.
@echo off
set name=%1
taskkill /F /IM %name%
del %name%
ren %name%.temp %name%
start %name%
exit
Am I missing something in this piece of batch code? Thanks