Delete an executable file ( .exe ) after finishing without knowing its location?

Asked

Viewed 95 times

1

The bat file has been converted to executable.
The command del "%~f0" does not work! You will need to finish running the executable first taskkill /f "nome_do_executável.exe" and only then eliminate it?

Question:
- How to find the file in windows and delete it?

Thanks @Sachadee for %~dpnx0!

start "nome_da_aplicação" cmd.exe /k "mode 90,5 & del /s /q %~dpnx0 >nul 2>&1 & exit"
  • tested del "%~dpnx0"at the end of the script ?

  • @Sachadee yes, thank you!

  • Where can I find information about dpnx'?

  • with for /? (last screen)

  • @Sachadee, thank you!

  • @Sachadee, The remote control del /s /q "%~dpnx0" seems not to be working on the executable... But if you use start cmd /k "del /s /q %~dpnx0" works, only a new window opens! How to close this window in one command? Ex: start cmd /k "del %~dpnx0 & exit /b"?

  • run taskkill can cause Windows Defender to delete its executable file

  • @Sveen Como... like this? taskkill /F /FI "WindowTitle eq Administrator: nome_do_programa" /T >nul 2>&1 & del /s /q "%~dpnx0" & exit /b?

  • If you use start cmd /k "del %~dpnx0" it will work (but then a command line is open), only if you finish the command line with taskkill! It seems a bit hammered... There is no possibility to do everything together within the ""?

  • Windows Defender checks whether the program runs a command as taskkill and classifies with malware.

  • Try it this way @b8engl : start cmd /k "del %~dpnx0 && exit"

  • @ Sachadee Well played!

Show 7 more comments

1 answer

1


You can use this at the end of the bat script :

start cmd /k  "del %~dpnx0"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.