SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Get and dislpay Default Gateway with ActionScript

Last post 08-04-2008, 8:55 by The_Q?. 8 replies.
Sort Posts: Previous Next
  •  07-07-2008, 11:12 13228

    Get and dislpay Default Gateway with ActionScript

    Hi everyone. I'm not very active on these forums and this is my first thread. I apologize if I put it in the wrong place...

    There's a flash applicaiton that's being developed for my company by a provider. The application runs off a CD and assists the user in setting up an internet connection.It needs to have a hyperlink to the user's default gateway (in other words, the router) that when clicked, brings up the router logon and subsequently router settings.

    Simply put, how would one query the machine to find it's default gateway?

    I know you can run the ipconfig command to check a machine's IP settings (including default gateway) and output it to a textfile using the >> switch. Could you then perhaps step through the file, find the String "Default Gateway . . . . :" and assaign what is on the right of it to a variable? I'm clueless when it comes to this type of scripting Tongue Tied

     The developer says he's having trouble with it. I know there must be a simple solution to this...

     Thanx in advance for any assistance...


    "The sky is hard" - Caboose from Red vs Blue, lying on the ground after a failed attempt to fly.
  •  07-07-2008, 13:08 13229 in reply to 13228

    Re: Get and dislpay Default Gateway with ActionScript

    It is quite easy. To demo, create a C# console app, add a reference to System.Net and add the following to the Main method:

     

                foreach (NetworkInterface networkCard in NetworkInterface.GetAllNetworkInterfaces())
                {
                    foreach (GatewayIPAddressInformation gatewayAddr in networkCard.GetIPProperties().GatewayAddresses)
                    {
                        Console.WriteLine("{0}:", networkCard.Name);
                        Console.WriteLine(gatewayAddr.Address);
                    }

                }
                Console.ReadKey();



    Driven Software
  •  07-07-2008, 15:46 13235 in reply to 13228

    Re: Get and dislpay Default Gateway with ActionScript

    Thanks. Will foward this information onto the developer. Hopefully they can do a similar thing from ActionScript...


    "The sky is hard" - Caboose from Red vs Blue, lying on the ground after a failed attempt to fly.
  •  07-07-2008, 16:46 13237 in reply to 13229

    Re: Get and dislpay Default Gateway with ActionScript

    Hmm, sorry, i should pay more attention - I didn't realise you wanted to do this inside ActionScript itself (yeah, I know, the subject line is a bit of a giveaway on that, but it has been one of those days).

    Ignore me.

     


    Driven Software
  •  07-07-2008, 16:55 13238 in reply to 13237

    Re: Get and dislpay Default Gateway with ActionScript

    Can you access WMI* through ActionScript? You can get this information that way, so if your dev can make WMI calls then that is the route to take it.

     

    * Windows Management Instrumentation


    Driven Software
  •  07-10-2008, 8:55 13267 in reply to 13238

    Re: Get and dislpay Default Gateway with ActionScript

    Ignore you? But why good sir? You have thaught me something and it shall be remembered...

    Searching for a way to write code to access WMI directly through ActionScript has lead me nowhere (google does not love me). But then, I thought how about running C# code from ActionScript? Surely this must be within the realm of possibility...

    There's this command line utility called jsc. Here's the link: http://jsc.sourceforge.net/

    And the tutorial link from the site for exactly C# to ActionScript, from the site above: http://docs.google.com/View?docid=dfmc8fvr_178g9q3p2gh

    Yes. It is a long winded solution, but it is a solution none the less. Plus, in future I just point the dev in the direction of C# and can get anything done! (more or less)

    Thanx a million


    "The sky is hard" - Caboose from Red vs Blue, lying on the ground after a failed attempt to fly.
  •  07-28-2008, 16:39 13737 in reply to 13267

    Re: Get and dislpay Default Gateway with ActionScript

    Strangely, having been the one to present the "proposed solution" to the developers, I find myself being the one too have too produce the solution. Sigh...

    I followed the tutorial with a little success. I tried your code but got some errors. I figured it's that "console" stuff so I took it out. I fiddled a bit and replaced with some code to create a textfield, but to no avail...

    I'm sure that it can be done... But how?

     


    "The sky is hard" - Caboose from Red vs Blue, lying on the ground after a failed attempt to fly.
  •  07-30-2008, 9:27 13766 in reply to 13737

    Re: Get and dislpay Default Gateway with ActionScript

    I know nothing about ActionScript, so I doubt if I can assist you, but if you post the error messages that you are getting then I can probably shed some light on them if they are .NET related.

     


    Driven Software
  •  08-04-2008, 8:55 13869 in reply to 13766

    Re: Get and dislpay Default Gateway with ActionScript

    No worries Kevin. A solution has finally been reached (albeit a little cumbersome). Just some feedback about how we solved this for anyone wanting too know...

     
    I presume that your code was spot on & that it was jsc (the cross-compiler) that was probably the issue. I figured because flash didn't have this functionality to begin with, the cross-compiler could not interpret the code into something the ActionScript would recognize. Thanx for the the effort though...

    My original long winded way off sending the output of the ipconfig command to textfile, then searching through the default gateway via script was what we used. From within flash, we got a utility to make use of windows batch files to create and cleanup the textfiles.

    In the end, it all worked out. Just not exactly the way planned...

    Thanx again. 


    "The sky is hard" - Caboose from Red vs Blue, lying on the ground after a failed attempt to fly.
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems