accesing local exe file from asp.net application
i am having a intranet asp.net application , all the clients connected to it is having a specific .exe file in their local disk, now i want to execute the .exe file from the .net application hosted in a intranet server. i used this code to do that
Dim psi As New System.Diagnostics.ProcessStartInfo()
psi.WorkingDirectory = "C:\\"
psi.FileName = "file:///c:/Project1.exe"
psi.Arguments = cTimeMaster.APQPID
psi.UseShellExecute = False开发者_StackOverflow中文版
System.Diagnostics.Process.Start(psi)
but it is throwing a error the system cannot find the file specified. is it having a permission issue on local system or any thing else, any help would be greatly appriciated. thanks and regards
As Darin and you mentioned, the exe lies on the client. Your VB.NET code in contrast runs on the server. It tries to find the exe file on the c:\ drive of the server.
If you want to access a file on the client you will need to add some client-side code. This induces a lot of security-related and technical constraints - I'm struggling with these right now myself...
For client-side code you could consider MS Silverlight (which allows you to code in VB.NET and do quite many things), or you can embed a VBScript or JavaScript in the HTML page you render, just google for "run exe from javascript" or "run exe from vbscript" and find e.g. http://www.dotnetspider.com/resources/19547-Run-exe-file-Java-Script.aspx (however, this only works in Internet Explorer).
Always keep in mind that ASP.NET is a server-side technology. The VB.NET code is compiled into an assembly which runs on the server. It renders (usually) an HTML page and sends it to the client, then the browser on the client presents that page, so code that should run on the client must be rendered into the HTML page.
The file is located on the client computer. For security reasons you cannot execute files located on the client computer using ASP.NET.
精彩评论