China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 14:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How can a BAT file kill itself after it runs successfully? View 1,337 Replies 11
Original Poster Posted 2010-03-16 14:34 ·  中国 天津 联通
初级用户
★★
Credits 173
Posts 69
Joined 2007-08-07 22:40
19-year member
UID 94807
Gender Male
Status Offline
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?
Floor 2 Posted 2010-03-17 10:31 ·  中国 天津 电信
初级用户
★★
Credits 128
Posts 122
Joined 2009-09-21 06:24
16-year member
UID 152378
Gender Male
Status Offline
Add del %0 on the last line
Floor 3 Posted 2010-03-20 11:53 ·  中国 广东 广州 从化区 电信
新手上路
Credits 4
Posts 2
Joined 2010-03-19 20:02
16-year member
UID 162589
Gender Male
Status Offline
Support
Floor 4 Posted 2010-03-21 20:01 ·  中国 河南 郑州 电信
新手上路
Credits 11
Posts 8
Joined 2010-03-19 19:18
16-year member
UID 162586
Gender Male
Status Offline
Learning this too. OP, could it be that you're making a virus?
Floor 5 Posted 2010-03-21 21:55 ·  中国 北京 联通
新手上路
Credits 10
Posts 4
Joined 2007-07-04 00:45
19-year member
UID 93070
Gender Male
Status Offline
Floor 6 Posted 2010-03-22 09:48 ·  中国 山东 临沂 联通
初级用户
Credits 38
Posts 24
Joined 2010-03-21 19:42
16-year member
UID 162709
Gender Male
Status Offline
rem delete itself
del %0
Floor 7 Posted 2010-03-22 19:18 ·  中国 吉林 长春 电信
初级用户
Credits 69
Posts 46
Joined 2010-03-18 11:14
16-year member
UID 162446
Gender Male
From 山东
Status Offline
Aha, I tried it and it worked... I was worrying about this, haha
Floor 8 Posted 2010-03-22 19:19 ·  中国 吉林 长春 电信
初级用户
Credits 69
Posts 46
Joined 2010-03-18 11:14
16-year member
UID 162446
Gender Male
From 山东
Status Offline
So del "%~0" and del %0 have the same effect
Floor 9 Posted 2010-03-25 09:28 ·  中国 江苏 苏州 电信
新手上路
Credits 10
Posts 5
Joined 2010-03-23 09:40
16-year member
UID 162830
Gender Male
Status Offline
New here, keeping an eye on this.
Floor 10 Posted 2010-04-05 11:12 ·  中国 广西 防城港 电信
初级用户
Credits 23
Posts 17
Joined 2010-03-30 17:53
16-year member
UID 163429
Gender Male
Status Offline
Let me take a look
Floor 11 Posted 2010-04-05 12:49 ·  中国 广东 佛山 顺德区 电信
初级用户
★★
Credits 151
Posts 106
Joined 2009-10-09 21:24
16-year member
UID 152856
Gender Male
From 河南省
Status Offline
del "%~0" and del %0 Could an expert please explain, what's the difference between the two, and which one should be used
Floor 12 Posted 2010-04-05 13:09 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
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
Forum Jump: