Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
scienceguru1.bat
- Posts: 44
- Joined: 01 Jan 2011 20:54
#1
Post
by scienceguru1.bat » 01 Jan 2011 21:14
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!
-
aGerman
- Expert
- Posts: 4705
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 01 Jan 2011 21:36
A
call /? should give you the answer.
Try
del "%~f0"or
del %~fs0Please don't tell me what this is good for, I don't wanna know
Regards
aGerman
-
scienceguru1.bat
- Posts: 44
- Joined: 01 Jan 2011 20:54
#3
Post
by scienceguru1.bat » 01 Jan 2011 21:40
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?
-
aGerman
- Expert
- Posts: 4705
- Joined: 22 Jan 2010 18:01
- Location: Germany
#4
Post
by aGerman » 01 Jan 2011 21:53
%~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