lrstndm Posted September 3, 2013 Share Posted September 3, 2013 I just started using object using autoit, I want to get some information from IIS. Searching the internet I found this piece of code in VBScript Set oIIS = GetObject("winmgmts:rootWebAdministration")Set oSite = oIIS.Get("Site.Name='Default Web Site'") WScript.Echo "Retrieved an instance of Site " WScript.Echo " Name: " & oSite.Name WScript.Echo " ID: " & oSite.ID Trying to convert the code and searching the forum I made this piece of code.... $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler $oIIS = ObjGet("winmgmts:root\WebAdministration") $oSite = $oIIS.Get("Site.Name='Default Web Site'") MsgBox(0, '', $oSite.Name & Chr(13) & $oSite.ID) Exit Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc When running the code I got some exception while getting the objects, what am I doing wrong? Regards, lrstndm Link to comment Share on other sites More sharing options...
Andreik Posted September 3, 2013 Share Posted September 3, 2013 Put #RequireAdmin at start of your script. For some providers you need adiminstrator rights. trancexx 1 Link to comment Share on other sites More sharing options...
lrstndm Posted September 3, 2013 Author Share Posted September 3, 2013 Yes you're right. But this won't work for me this time. Link to comment Share on other sites More sharing options...
Andreik Posted September 3, 2013 Share Posted September 3, 2013 If I run the script above I get this: Default Web Site 1 Link to comment Share on other sites More sharing options...
lrstndm Posted September 3, 2013 Author Share Posted September 3, 2013 Allright.... Do you know what could cause the problem? I ran it on a Vista 32-bit system and a Windows 7 64-bit system. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now