knuefi
Goto Top

Script, was mache ich verkehrt?

Hallo zusammen,
ich hoffe mir kann jemand von euch helfen. Ich wollte mit diesen Script 3 Ordner überwachen und bei Eingang soll ein Programm starten. Leider läuft es nicht und ich finde den Fehler nicht face-sad
Const strPath = "D:\A"  
Const strPath2 = "D:\B"  
Const strPath3 = "D:\C"  
Const intInterval = "2"  
strDrive = Split(strPath,"\")(0)  
strFolder = Replace(Split(strPath,":")(1),"\","\\") & "\\"  

strDrive2 = Split(strPath2,"\")(0)  
strFolder2 = Replace(Split(strPath2,":")(1),"\","\\") & "\\"  

strDrive3 = Split(strPath3,"\")(0)  
strFolder3 = Replace(Split(strPath3,":")(1),"\","\\") & "\\"  

Set fso = WScript.CreateObject("Scripting.Filesystemobject")  
Set objShell = CreateObject("Wscript.Shell")  
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2" )  

strQuery = "Select * From __InstanceOperationEvent" _  
    & " Within " & intInterval _  
    & " Where Targetinstance Isa 'CIM_DataFile'" _  
    & " And ((TargetInstance.Drive='" & strDrive & "'"_  
    & " And TargetInstance.Path='" & strFolder & "') or "_  
    & "(TargetInstance.Drive='" & strDrive2 & "'"_  
    & " And TargetInstance.Path='" & strFolder2 & "')) or"_  
    & "(TargetInstance.Drive='" & strDrive3 & "'"_  
    & " And TargetInstance.Path='" & strFolder3 & "')))"  
Set colEvents = objWMIService.ExecNotificationQuery (strQuery) 
Do 
    Set objEvent = colEvents.NextEvent()
    Set objTargetInst = objEvent.TargetInstance
    
    Select Case objEvent.Path_.Class 
        Case "__InstanceCreationEvent"  
            objShell.Run """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""  
    End Select 
Loop

Content-Key: 307648

Url: https://administrator.de/contentid/307648

Printed on: April 23, 2024 at 09:04 o'clock

Mitglied: 129813
Solution 129813 Jun 19, 2016 updated at 16:34:24 (UTC)
Goto Top
Look at the parentheses in your notification query, they are not distributed correctly face-wink
strQuery = "Select * From __InstanceOperationEvent" _  
    & " Within " & intInterval _  
    & " Where Targetinstance Isa 'CIM_DataFile'" _  
    & " And ((TargetInstance.Drive='" & strDrive & "'"_  
    & " And TargetInstance.Path='" & strFolder & "') or "_  
    & "(TargetInstance.Drive='" & strDrive2 & "'"_  
    & " And TargetInstance.Path='" & strFolder2 & "') or"_  
    & "(TargetInstance.Drive='" & strDrive3 & "'"_  
    & " And TargetInstance.Path='" & strFolder3 & "'))"  
Regards
Member: Knuefi
Knuefi Jun 19, 2016 at 17:12:27 (UTC)
Goto Top
)))

perfect thank you