Advertisement

05.08.2007 at 02:18PM PDT, ID: 22560220
[x]
Attachment Details

Scripting help, it is not working right...  still learning

Asked by burstadmin in Scripting Languages, Microsoft Windows Operating Systems

Tags: rar, winrar, working

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.Shell")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 50 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts\\\\_upload""'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    strNewFile = objLatestEvent.TargetInstance.PartComponent
    arrNewFile = Split(strNewFile, "=")
    strFileName = arrNewFile(1)
    strFileName = Replace(strFileName, "\\", "\")
    strFileName = Replace(strFileName, Chr(34), "")
    objShell.Run("c:\deletefiles.bat")
loop



And my Deletefiles.bat file


copy c:\scripts\_offline\_app_offline.htm c:\scripts\_current\app_offline.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_offline.htm c:\scripts\_current\app_offline.htm
"c:\program files\winrar\unrar" x c:\scripts\_upload\cur*.rar c:\scripts\_current\
move c:\scripts\_upload\*.rar c:\scripts\_archive
del c:\scripts\_current\app_offline.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
[+][-]05.08.2007 at 03:12PM PDT, ID: 19053405

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, Microsoft Windows Operating Systems
Tags: rar, winrar, working
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.08.2007 at 06:20PM PDT, ID: 19054154

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2007 at 02:55PM PDT, ID: 19250128

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.16.2007 at 06:39PM PDT, ID: 19300292

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32