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-ID: 307648

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

Ausgedruckt am: 22.11.2024 um 04:11 Uhr

129813
Lösung 129813 19.06.2016 aktualisiert um 18:34:24 Uhr
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
Knuefi
Knuefi 19.06.2016 um 19:12:27 Uhr
Goto Top
)))

perfect thank you