alanwsg Posted January 12, 2011 Posted January 12, 2011 I have a simple script that I use to control my netgear router ... $oXML = ObjCreate("Microsoft.XMLHTTP") $oXML.Open("GET", "http://192.168.0.1/setup.cgi?todo=" & $CmdLine[1] & "&wan=1", True, "admin", $CmdLine[2]) $oXML.Send I call the script from a Java application and provide the 'todo' option & password as command line options. When it works it's fine. But if it can't contact the router it popups-up a box saying something like "Script failed at Line -2" and then hangs waiting for user input. Can I somehow prevent it from generating the popup and hanging and just return an error code instead?
ZacUSNYR Posted January 12, 2011 Posted January 12, 2011 Check out the section in the help file Obj/COM Reference. There is a COM Error Handling section that'd be worth a read for you. Also search this site. One thing you can do is if you know you're failing due to connection you could do a 'ping' first. Ping("192.168.0.1") If NOT @error Then $oXML = ObjCreate("Microsoft.XMLHTTP") $oXML.Open("GET", "http://192.168.0.1/setup.cgi?todo=" & $CmdLine[1] & "&wan=1", True, "admin", $CmdLine[2]) $oXML.Send EndIf
alanwsg Posted January 12, 2011 Author Posted January 12, 2011 Thanks for that, found a solution with a bit of cut&pasting from the Obj/COM Reference help section.
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