简体   繁体   中英

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
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

The file is located on the client computer. For security reasons you cannot execute files located on the client computer using ASP.NET.

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 eg 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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM