I am still learning scripting, so not all of this is easy to understand yet... But I have a script that monitors a directory ever minute. If a RAR file is dropped into this directory, then it is automaticly unRAR'd to the appropriate directory, then the RAR file is supposed to be moved to an Archive directory. Here is the monitor script:
Set objShell = CreateObject("Wscript.Shel
l")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotifica
tionQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 50 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile
' and " _
& "TargetInstance.GroupCompo
nent= " _
& "'Win32_Directory.Name=""c
:\\\\scrip
ts\\\\_upl
oad""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEve
nt
strNewFile = objLatestEvent.TargetInsta
nce.PartCo
mponent
arrNewFile = Split(strNewFile, "=")
strFileName = arrNewFile(1)
strFileName = Replace(strFileName, "\\", "\")
strFileName = Replace(strFileName, Chr(34), "")
objShell.Run("c:\deletefil
es.bat")
loop
And my Deletefiles.bat file
copy c:\scripts\_offline\_app_o
ffline.htm
c:\scripts\_current\app_of
fline.htm
start /w wscript.exe sleep.vbs
@ECHO OFF
FOR /F "tokens=1 usebackq" %%a IN (`DIR c:\Scripts\_current /AD /B`) DO RD c:\Scripts\_current\%%a /S /Q
DEL c:\Scripts\_current\* /A /F /Q
copy c:\scripts\_offline\_app_o
ffline.htm
c:\scripts\_current\app_of
fline.htm
"c:\program files\winrar\unrar" x c:\scripts\_upload\cur*.ra
r c:\scripts\_current\
move c:\scripts\_upload\*.rar c:\scripts\_archive
del c:\scripts\_current\app_of
fline.htm
pause
The move is not working, and the pause is not working... Is there something in the batch file that is killing the script and causing the batch file to quit? The del c:\scripts... does work... any ideas on what I am doing wrong? Also, can't I do all of this in the script to make it easier??? any help would be apreaciated...
Start Free Trial