Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Launch EXE from SL 2.0 RSS

11 replies

Last post Apr 15, 2009 03:53 PM by Snake2k

(0)
  • SandraM

    SandraM

    Member

    18 Points

    6 Posts

    Launch EXE from SL 2.0

    Jun 02, 2008 04:23 PM | LINK

    How can I launch an executable (for example: C:\Windows\System32\Calc.exe) from within SL 2.0?  Tried CreateProcess, but receive an exception of type 'System.MethodAccessException'.

     Any help would be greatly appreciated!

    Launch Executable

  • sladapter

    sladapter

    All-Star

    43607 Points

    7907 Posts

    Re: Launch EXE from SL 2.0

    Jun 02, 2008 04:36 PM | LINK

    You want to launch an executable from the Client machine? I don't think you can do that. That's will break the basic security rule of a web application. If you could do that you could do all kinds of hacking to the client machine. Do you want to run any web application that will launch some exe on your machine without you knowing it?

     

     

     

     

     

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • pbromberg

    pbromberg

    Contributor

    3138 Points

    531 Posts

    Re: Launch EXE from SL 2.0

    Jun 02, 2008 05:11 PM | LINK

    The only client-side filesytem access allowed is the IsolatedStorage area.  Can you imagine if some rogue Silverlight application were allowed to run:

    cmd.exe
    del C:\*.* /s

    ??

    [C# MVP]
    Eggheadcafe.com
  • SteveWong

    SteveWong

    Contributor

    6719 Points

    1346 Posts

    Re: Launch EXE from SL 2.0

    Jun 02, 2008 05:48 PM | LINK

    Can you take a look on this post posted before?

    I think it may help you

    http://silverlight.net/forums/p/16610/55144.aspx#55144

    Regards,
    SteveWong (HongKong)
    Please mark post as answer if they help you
  • SandraM

    SandraM

    Member

    18 Points

    6 Posts

    Re: Launch EXE from SL 2.0

    Jun 02, 2008 05:59 PM | LINK

    Thank you all for your quick responses.  This is my first time doing web development and I seem to be stuck in the "Windows Development" mode.

    Can SL 2.0 launch an exe from any other location?  (not on the client's machine) 

  • mchlSync

    mchlSync

    Star

    14968 Points

    2799 Posts

    Re: Launch EXE from SL 2.0

    Jun 03, 2008 08:43 AM | LINK

    SandraM

    Can SL 2.0 launch an exe from any other location? 
     

    No.  

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Regards,
    Michael Sync
    Silverlight MVP

    Blog : http://michaelsync.net
  • sladapter

    sladapter

    All-Star

    43607 Points

    7907 Posts

    Re: Launch EXE from SL 2.0

    Jun 03, 2008 02:19 PM | LINK

     I guess you can launch an exe from your server by a WebService call if you really want to. But what is the purpose of doing this? The Silverlight is running on your client machine. The exe you launched will be running on the server. Unless you want to do some back end processing using the exe then send the result back to the Silverlight side.

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • SpoonStomper

    SpoonStomper

    Member

    114 Points

    38 Posts

    Re: Launch EXE from SL 2.0

    Jun 03, 2008 06:07 PM | LINK

    Silverlight can call JavaScript which can use ActiveX to run an exe. Presuming you want to launch the exe on the client.

    Caveat:

    1. Presumes the exe is in the same place on every computer.
    2. There are some browser security setting to deal with.
    3. Kind of kills the cross browser/platform appeal of your application (I think active x is a windows only thing)

    Java script for executing an exe:

    <script language="javascript" type="text/javascript">
    function runApp()
    {
     var shell = new ActiveXObject("WScript.shell");
     shell.run("\"PATH_TO_FILE\"");
     return false;
     }
    </script>

    Notes:

    1. need \" around path to handle spaces in the path
    2. return false was in there because this was used during a Button.OnClientClick to prevent the post back

    This thread appears to have the answer on calling javascript from silverlight.
    http://silverlight.net/forums/p/10266/33114.aspx#33114

  • SandraM

    SandraM

    Member

    18 Points

    6 Posts

    Re: Launch EXE from SL 2.0

    Jun 06, 2008 05:59 PM | LINK

    Thank you all for your answers.  You are all right, I shouldn't be able to launch an executable located on the clients machine, as that is a big web development "no no".  I was able to find a sufficient work around for my issue.

  • inbal11

    inbal11

    Member

    2 Points

    4 Posts

    Re: Re: Launch EXE from SL 2.0

    Jun 12, 2008 08:53 PM | LINK

    How did you manage to solve it, i have the same problem