Jump to content

Recommended Posts

Posted

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?

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...