A
A
Anatoly Belousov2021-11-18 14:11:34
Python
Anatoly Belousov, 2021-11-18 14:11:34

EXE file is not deleted. What to do?

Good day!
There is a python test.exe file that runs btest.bat : In btest.bat :
os.system('C:\\btest.bat') # запускает btest.bat

taskkill /im test.exe   # завершает процесс
del "C:\test.exe"         # удаляет исполняемый test.exe

For some reason, test.exe is not removed until you run btest.bat manually! How can I fix this so that btest.bat ends the test.exe process itself and deletes it?

SOLUTION THAT HELPED ME:
taskkill /f /im test.exe   # завершает процесс
del "C:\test.exe"         # удаляет исполняемый

Added the /f flag to the taskkill line

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2021-11-18
@Zoominger

'C:\\btest.bat'

Have you tried a single slash?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question