谁能帮我给这个程序加一个延时代码?

来源:百度知道 编辑:UC知道 时间:2024/07/07 03:10:30
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 清除系统LJ完成!
echo. & pause

如果可以的话,最好再加一个不能强行关闭的代码,谢谢
我的意思是让该程序连同cmd的对话框同时延时打开,也就是说,当我双击它之后暂时先不启动,等过几分钟之后在自动运行。有没有办法?

实现延时的话, 如果精度要求不高的话可以用ping命令
如:ping -n 3 127.0.0.1>nul大约可以停顿2秒
-n后的数字是发送包的数目,为暂停秒数加一。此法每秒有0.5%的偏差,时间精度为1秒。

补充: 我能想到的办法只有写程序实现了
用VC++新建一个Windows程序的project, 然后在winmain的实现里:

Sleep(10000); //延时10秒, 你自己可以按要求改的

//执行一个DOS批处理, 第三,第五个参数也要按你的要求改下
ShellExecute(NULL, NULL, "C:\\a.bat", NULL, "C:\\", SW_SHOW);
编译并运行这个程序应该能满足你的要求

恐怕不行吧,DOS程序只要点“关闭”就肯定退出了,不能强行关闭,那不就死机了。

病毒????

1、暂停(Pause)、延迟(Delay)、等待(Wait)、睡眠(Sleep)

1)for+set+if,时间精度为0.01秒,适用平台为WinNT/2K/XP/2003。

利用for解析变量%time%并存为两个时间点%start%和%now%,再利用set /a计算两个时间点的时间差,最后用if判断时间差是否达到设定的暂停时间。
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------

@echo off
setlocal enableextensions
echo %time%
call :ProcDelay 200
echo %time%
goto :EOF

:ProcDelay delayMSec_
setlocal enabl