delete itself and close the window

March 13, 2009 at 21:01:24
Specs: Windows Vista Ultimate SP1 x64, 2 GB
One batch file uses start command to open another.

Just like the description in "start /?" sais:

If it is an internal command or a batch file then
the command processor is run with /K switch to cmd.exe.
This means that window will remain after the command
has been run.

Adding the exit command at the end of batch file
will close the window.

The thing is I need that second batch to delete itself,
and then exit.

del %0

But, of course, after file deletes itself exit command
won't be run and window will remain open.

I had in mind using call to open the second batch,
and then using taskkill to close the first one.
This way the second batch would close automatically
after it deletes itself.

But both batches are cmd.exe processes and
therefore I can't specify which one to kill.

Does anyone has an idea how to do this?

See More: delete itself and close the window

Report •

March 13, 2009 at 21:09:41

Start cmd /c "<batch>"

Report •

March 14, 2009 at 04:30:32
Works like a charm. :D

Report •

Related Solutions

Ask Question