1
我忙上一個cmd程序(使用Windows &和運行CMD作爲管理員),它會做以下工作:基於時間的CMD退出
- 檢測連接到網絡中的所有計算機和寫入文本文件(這部分工作正常)
- 退出程序,如果計算機的時間等於例如下午12時
該程序如下:
@ECHO OFF
color a
: Begin
IF %Time% /t GTQ 01:15 && %Time% /t LEQ 01:20 (GOTO END) <---- problem is here
% %
% Date stamp the log entry and copy values. Wait 3 min before redoing the scan and check time %
% %
Time /t >> C:\Users\Paimon\Desktop\"WIFI data.txt"
Date /t >> C:\Users\Paimon\Desktop\"WIFI data.txt"
netstat -n
netstat -n >> C:\Users\Paimon\Desktop\"WIFI data.txt"
timeout /t 180
cls
GOTO Begin
:END
exit
由於程序每3分鐘只執行一行,因此我決定將時間與一個肆意值進行比較。
+1,提出問題的優秀簡單解決方案。 – dbenham 2014-11-04 15:50:13
我害怕,Stephan,如果我將你的代碼插入到我現有的代碼中,cmd會返回錯誤:72在這個時候是意外的。 – 2014-11-05 08:02:51
'72'?七十二?沒有機會使用此代碼獲取該錯誤。刪除'@echo off'來查看會發生什麼。 – Stephan 2014-11-05 20:46:15