순전히 배치 파일로 수행하고자하는 일은 거의 없을 것 같습니다.
그러나 비교적 간단한/작은 VB 스크립트에서이 작업을 수행 할 수 있습니다.이 스크립트는 시스템에 추가로 설치할 필요가 없습니다.
'-------------------------------------------------------------
' Monitors a folder for new files and warns if they
' are not being created within a certain time period.
'-------------------------------------------------------------
Dim intMinutes: intMinutes = 5 ' minute threshold for warning of no new files
Dim strDrive: strDrive = "c:" ' drive to monitor
Dim strPath: strPath = "\\temp\\" ' path to monitor. remember to double slashes
Dim intTimer: intTimer = "2"
Dim strComputer: strComputer = "."
Dim objWMIService: Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim strQuery: strQuery = "Select * From __InstanceOperationEvent" & " Within " & intTimer & " Where Targetinstance Isa 'CIM_DataFile'" & " And TargetInstance.Drive='" & strDrive & "'" & " And TargetInstance.Path='" & strPath & "'"
Dim colEvents: Set colEvents = objWMIService. ExecNotificationQuery (strQuery)
Dim LastNew: LastNew = Now
WScript.Echo "Monitoring new file creation... Press [Ctrl]-[C] to exit"
Do
Set objEvent = colEvents.NextEvent()
Set objTargetInst = objEvent.TargetInstance
Select Case objEvent.Path_.Class
Case "__InstanceCreationEvent"
LastNew = Now
End Select
if DateDiff("n",LastNew,Now) >= intMinutes then
' put whatever actions you want in here... the following two lines are for demo purposes only
msgbox "The last new file was " & DateDiff("n",LastNew,Now) & " minute ago!",0,"No New Files"
exit do
end if
Loop
는 CScript를 볼 또는
하지 콘솔 창을 표시 할 수 있도록 에 WScript와는 이것을 실행합니다. IF 블록 내부의 코드를 바꿔 필요한 작업을 수행하십시오 (문제를 알려주십시오).
출처
2012-10-14 01:02:06
RLH