Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a SFX to extract some files. After the extraction, I need that the SFX file is deleted. As far as I have seen, WinRar does not offer such option. So I thought to run some DOS command -prompt (like bat).

This is my code so far (not working):

SETUP=cmd /c del /f /q "file-to-delete"

It opens the cmd, flashes and then closes...

Someone with a similar problem:

share|improve this question

migrated from Jun 6 '13 at 3:18

This question came from our site for professional and enthusiast programmers.

is your SETUP= a WinRar directive? Ensure the full path to the file is included. – foxidrive Jun 5 '13 at 13:34
Yes, "SETUP=" is AN winrar diretive and it allows to run a specific program after the SFX automatic extraction, which can be "Setup.exe" or "Install.exe" or "script.bat", etc... the path is fine I just can't find the way to make it works – Rafael Vidal Jun 5 '13 at 13:45
Your problem is that the SFX is still running, so if you try to delete it you're only going to end up with an Access Denied error. – Karan Jun 6 '13 at 4:42
Karan, that's not the case. Winrar have specicif directives to be used BEFORE, DURING or AFTER the exctraction process. In this case, the SETUP directive is excevuted at the ende (after SFX has finished). So there is no problem to delete the file. By the way, foxidrive has the exactly solution. Thank you by the way. – Rafael Vidal Jun 6 '13 at 23:32
Hmm, wonder why cmd doesn't work but cmd.exe does (with or without the full path, former is what %comspec% contains). So all you had to do was change your code to SETUP=cmd.exe /c del /f /q "name-of-sfx". – Karan Jun 8 '13 at 0:10
up vote 1 down vote accepted

See if this works - include the accurate path to the file and see if it deletes it. If it does then you can try relative paths.

SETUP="%comspec%" /c del "c:\program location\file-to-delete"

If that fails then include this command in a bat file located where the file is and then use the bat file to delete the SFX file, in the WinRar directive.

@echo off
del "file-to-delete"
share|improve this answer
PERFECT! "%comspec%" /c del "c:\program location\file-to-delete" made the trick. But how did you know? – Rafael Vidal Jun 6 '13 at 23:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .