中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 13:37
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » How can a BAT file kill itself after it runs successfully?
Printable Version  1,336 / 11
Floor1 ggyy66 Posted 2010-03-16 14:34
初级用户 Posts 69 Credits 173
How can a BAT file kill itself after it runs successfully?
What I want is for a batch file to delete itself after it runs. Can that be done?
One of my programs uses a batch file in order to implement self-updating,
and I don't want this batch file to be left behind.
I want it to delete itself as soon as it finishes running. How can I do that?
Floor2 jarry0932 Posted 2010-03-17 10:31
初级用户 Posts 122 Credits 128
Add del %0 on the last line
Floor3 davinciywf Posted 2010-03-20 11:53
新手上路 Posts 2 Credits 4
Support
Floor4 dujttk Posted 2010-03-21 20:01
新手上路 Posts 8 Credits 11
Learning this too. OP, could it be that you're making a virus?
Floor5 maddog Posted 2010-03-21 21:55
新手上路 Posts 4 Credits 10
Floor6 yiqingnan Posted 2010-03-22 09:48
初级用户 Posts 24 Credits 38
rem delete itself
del %0
Floor7 luuk Posted 2010-03-22 19:18
初级用户 Posts 46 Credits 69 From 山东
Aha, I tried it and it worked... I was worrying about this, haha
Floor8 luuk Posted 2010-03-22 19:19
初级用户 Posts 46 Credits 69 From 山东
So del "%~0" and del %0 have the same effect
Floor9 cdwang1011 Posted 2010-03-25 09:28
新手上路 Posts 5 Credits 10
New here, keeping an eye on this.
Floor10 xue1995 Posted 2010-04-05 11:12
初级用户 Posts 17 Credits 23
Let me take a look
Floor11 zaixinxiangnian Posted 2010-04-05 12:49
初级用户 Posts 106 Credits 151 From 河南省
del "%~0" and del %0 Could an expert please explain, what's the difference between the two, and which one should be used
Floor12 Hanyeguxing Posted 2010-04-05 13:09
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
Originally posted by zaixinxiangnian at 2010-4-5 12:49:
del "%~0" and del %0 Could an expert please explain, what's the difference between the two, and which one should be used

Just using del %0 is enough
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023