To Access Notepad, calculator through asp.net

前端 未结 6 851
孤街浪徒
孤街浪徒 2021-01-23 15:47

I m trying to open Notepad, Calculator in button click in asp.net with code behind C#. I tried with the code

 System.Diagnostics.Process.Start(\"c:\\\\windows\\\         


        
相关标签:
6条回答
  • 2021-01-23 15:47

    You cannot do this. ASP.NET runs on the server and you cannot run programs on the client computer. The ActiveX object you have shown should work but only in IE and only after the user explicitly authorizes the execution of it. Also the location of notepad.exe might differ depending on the client (could be c:\windows, c:\winnt, ... and some clients running for example on Linux or MacOS don't have such executable)

    0 讨论(0)
  • 2021-01-23 15:48

    This is not possible (in general, though you could possibly get around with with various applets and browser plugins). In fact, I would be quite mortified if any web page could execute an arbitrary program on my computer.

    0 讨论(0)
  • 2021-01-23 15:53

    What you are trying to achieve is not possible because of the nature of application in case of ASP.Net. The application will execute on server and will only send client side HTML to client. Even if your code is syntatically correct, it would open up the utilities on server itself.

    0 讨论(0)
  • 2021-01-23 15:55

    This can't be done. Imagine the security mess we'd be in if a web-page could run arbitrary programs on a client machine. Oh wait... ;-)

    0 讨论(0)
  • 2021-01-23 16:07

    This Can be possible by using below code on click of server button or Link. System.Diagnostics.Process.Start("notepad.exe");

    0 讨论(0)
  • 2021-01-23 16:13
    System.Diagnostics.Process.Start("C:\Windows\System32\calc.exe")
    

    Works fine, though you may have to adjust settings on your browser. Be sure calc.exe is in the directory.

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