![Rank: 2](images/default/star_level2.gif)
- 帖子
- 2
- 积分
- 106
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-9-25
|
原帖由 Lumiere 于 2009-9-25 16:32 发表 ![](http://bbs.bathome.net/images/common/back.gif)
看得有些晕……现在的人措辞……
您是哪个时代的?
呵呵。
版主提示用代码,下面就是代码:
----
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
@set TodayFileName="%date%.txt"
@if exist %TodayFileName% @goto FileExist
@echo %TodayFileName% > %TodayFileName%
:FileExist
@if exist %TodayFileName%.opened goto ExitPoint
@echo "opened" > %TodayFileName%.opened
@notepad %TodayFileName%
@del %TodayFileName%.opened
:ExitPoint
exit
----
其中
%TodayFileName%.opened
就是用来判断
%TodayFileName%
有没有已经被打开的临时文件。
----
如此这样的话,在关闭notepad后,%TodayFileName%.opened会被删除
但如果我在任务管理器中,把cmd这个进程关掉(或者直接关机),这个临时文件将不会被删除。
有没有办法可以规避这些例外? |
|