Ok sry my sniped was a bit to small i think. It looks like the error-event is the Problem :/ Global $oIEErrorHandler = ObjEvent("AutoIt.Error", "MyErrFunc")
; Datumswerte ermitteln
Global $DATUM = @YEAR & "-" & @MON & "-" & @MDAY
Global $ZEIT = @HOUR & ":" & @MIN & ":" & @SEC
Global $ZEITDATEI = @HOUR & "_" & @MIN & "_" & @SEC
Global $INIFILE = "test.ini"
#region WMI-Part
Local Const $wmiNamespace = "root\WMI"
Local $wbemFlagReturnImmediately=0x10
Local $wbemFlagForwardOnly=0x20
Local $objWMIServiceWMI = ObjGet("winmgmts:\\" & @ComputerName & "\" & $wmiNamespace)
If Not @error And IsObj($objWMIServiceWMI) Then
; Aktive Monitore abfragen
Local $colItems = $objWMIServiceWMI.ExecQuery("SELECT * FROM WmiMonitorID WHERE Active='True'", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
MsgBox ( 0, "Test Script", "Start")
For $objComputer In $colItems
MsgBox ( 0, "Test Script", "Monitor")
Next
MsgBox ( 0, "Test Script", "Ende")
EndIf
EndIf
#EndRegion
#region MyErrFunc
Func MyErrFunc($oError)
Local $HexNumber = hex($oError.number,8)
Local $Output = "err.description is: " & @TAB & $oError.description & @CRLF & _
"err.windescription:" & @TAB & $oError.windescription & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oError.helpcontext _
Local $file = FileOpen("Error_" & @ComputerName & "_" & $DATUM & "_" & $ZEITDATEI & "_" & Int(Random(1, 1000)) & ".clstartup.dat", 1)
If $file <> -1 Then
FileWrite($file, $Output)
FileClose($file)
EndIf
IniWrite($INIFILE, "ini", "wmi", "False")
IniWrite($INIFILE, "Error", "LastError", $DATUM & " " & $ZEIT)
IniWrite($INIFILE, "Error", "Scriptline", $oError.scriptline)
Exit
EndFunc ;==>MyErrFunc
#EndRegion
If i run this Script on my Windows 7 or Windows 8 Clients i get 3 Messageboxes (Start + Monitor + End) without Error-File.If i run this script on an 2008 Server i get only the "Start" with Error-File. If i comment out the first line i runes on the 2008 Server to like on Windows 7 and Windows 8. And i dont know why :/ And Error is every time the same: *EDIT* I found somthing: http://stackoverflow.com/questions/26851511/vbscript-swbemobjectset-error-8004100c 8004100c on swbemobjectset means "Not supported". But how could i catch this. Actual my Script exit if it get COM-Error. But it looks this Error is fine. But i cant handle it because @error would not bet set after ExecQuery :/ WmiMonitorID get suppored with Vista and Server 2008: http://msdn.microsoft.com/en-us/library/aa394542%28v=vs.85%29.aspx so dont know why this dont work. But i think it looks like not the Error from the base Thread sry