Run .exe on client system from server-side c# code

前端 未结 4 593
我在风中等你
我在风中等你 2020-12-20 02:32

I want to run an exe on client system from my c# asp.net website. When I use Process.Start() it throws an error:

The requested operation

相关标签:
4条回答
  • 2020-12-20 03:16

    You can't run an application from a web server like that. You will have to have the user download the application by supplying the EXE, a setup file or using ClickOnce.

    0 讨论(0)
  • 2020-12-20 03:18

    You can't spawn processes on the client machine from server-side code.

    When you use Process.Start in server-side code, it is attempting to execute the process there, on the server where the website is hosted. If you wanted to create processes on the clients computer then you would need to expose a download for them (and not in employing subterfuge, like malign sites might do to install software - supply it gracefully, and normally (and with permission)), or a Silverlight application or something along those lines.

    The bottom line is that the code you want to execute (even if that is just to spawn a process) must reside on the client, and be executed there.

    0 讨论(0)
  • 2020-12-20 03:19

    Or you can develop an ActiveX control that you can have the browser automatically download from a Trusted Internet Zone.

    Once downloaded, proper signing with a certificate (signed from the trusted (corporate) root certificate) will avoid the user getting a prompt to ask whether he wishes to allow the ActiveX control to install/be activated -

    The ActiveX control can subsequently do anything the interactively logged on user could. This means that to actually install a program you'd need to elevate (UAC on Vista+); But if the goal was just to run a standalone executable, you should be good to go.

    This all assumes white-hat purposes in a (larger) corporate setting, because it relies on PKI infrastructure and central browser policies, to name just two.**

    This would, really, lead to some excellent questions on serverfault or superuser

    0 讨论(0)
  • 2020-12-20 03:34

    I noticed you said you wanted to run an exe file on the client, but you didn't say explicitly that the exe is on the server and you want to push it to the client. Everyone seems to be assuming that is the case.

    You CAN accomplish this fairly easily with a small JavaScript if you have a few prerequisites:

    1. The executable is already present on the client machine.
    2. All of your clients are running IE
    3. You can enforce a policy to put your site in the Intranet or Trusted Sites zone.

    So basically this means it's a corporate intranet application. I am assuming this is probably the case since, well, if you were expecting to do this with a public app, I would be surprised.

    For the script to accomplish this, please see my answer to this question:

    How can I get a program on a client machine to run from an ASP.NET page?

    0 讨论(0)
提交回复
热议问题