Sign in to follow this  
Followers 0
alanwsg

Stopping popups when script fails

3 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Thanks for that,

found a solution with a bit of cut&pasting from the Obj/COM Reference help section.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0