Board logo

标题: [求助]del %0 的问题 [打印本页]

作者: yiyepianzhou     时间: 2007-11-21 15:11    标题: [求助]del %0 的问题
在我的c:\windows下和我的u盘下都有一个叫test.bat的批处理
并且一模一样。
在它的代码最后有一句是del %0,
我运行c:\windows中的test.bat,
我想让它删除自己,但是我把u盘插上后,u盘中的test.bat被删除了,
而 c:\windows中的还在。
有点奇怪

作者: scriptor     时间: 2007-11-21 18:03
试一试这个

del %~n0

作者: scriptor     时间: 2007-11-21 18:04
Originally posted by yiyepianzhou at 2007-11-21 15:11:
在我的c:\windows下和我的u盘下都有一个叫test.bat的批处理
并且一模一样。
在它的代码最后有一句是del %0,
我运行c:\windows中的test.bat,
我想让它删除 ...


del %0
可以自删除啊~~
我刚试过了!!

你的是怎么回事呢~~

作者: fastslz     时间: 2007-11-21 21:12
del "%0"

作者: alchemist     时间: 2007-11-22 12:52
Batch file missing

作者: yiyepianzhou     时间: 2007-11-22 14:16
我试了一下:
在u盘里有一个test.bat
@echo off
del test.vbs
ping 127.1 -n 3
del %0

一个test.vbs
Dim hw
Set hw=WScript.CreateObject("WScript.Shell")
hw.Run "c:\windows\test.bat" ,0,true

一个dy.bat
@echo off
copy test.bat %systemroot%
copy test.vbs %systemroot%
start %systemroot%\test.vbs

用dy.bat将test.vbs 与test.bat复制到%systemroot%中
再运行test.vbs,test.bat可以删除自己,但不能删除%systemroot%中的test.vbs,反而将u盘中的test.vbs给删了。
如果不用dy.bat来运行test.vbs,而是直接在%systemroot%中去运行,
结果就正常了。
如果将test.vbs改为:
Dim hw
Set hw=WScript.CreateObject("WScript.Shell")
hw.Run "test.bat" ,0,true
用dy.bat重复上面并用它来运行改过后的test.vbs,
就是u盘中的test.bat和test.vbs都被删了windows中的就没有。

作者: Dos2008     时间: 2007-11-22 17:48
可以删除本身呀,我一直都这样用的!没出过问题!

作者: toolpc     时间: 2009-1-13 19:05
局驭网的VBS.
可以删除的
肯定你路镜没写好..标明