I am trying to make a batch file that at the end will delete it's self. I have already tried once, using:
DEL %~dp0% [file name]
and deleted by desktop in the doings . I have a idea, but i wanted to check with someone else before I mess up again. My new idea is:
DEL %~dp0%%1 prompt $
Do you think this will work? If not, what should I do to fix it.
Thanks!
self-delete line
Moderator: DosItHelp
Re: self-delete line
A call /? should give you the answer.
Try
del "%~f0"
or
del %~fs0
Please don't tell me what this is good for, I don't wanna know
Regards
aGerman
Try
del "%~f0"
or
del %~fs0
Please don't tell me what this is good for, I don't wanna know
Regards
aGerman
-
- Posts: 44
- Joined: 01 Jan 2011 20:54
Re: self-delete line
i am trying to make a batch that downloads a file, then deletes it's self so it can' tbe share with others. the only file i am trying to delete in the end is the batch that i am running. will what you gave JUST delete the batch that is running?
Re: self-delete line
%~f0 expands to the file's own full name. Enclose it in double quotes if the path or file name contains spaces.
%~fs0 expands to the full short name.
You could always check it by ECHOing.
Regards
aGerman
%~fs0 expands to the full short name.
You could always check it by ECHOing.
Code: Select all
echo "%~f0"
echo %~fs0
Regards
aGerman