简体   繁体   中英

run exe on server side from an asp.net Web page

I need to run an exe located on the server in the same folder of the aspx web page
I have a button in the web page which when clicked will execute the exe and bring up the App Form.

This is the code-behind of the button present in the aspx page.

Protected Sub RunBtn_Click(sender As Object, e As EventArgs) Handles RunBtn.Click
    Dim process1 As New System.Diagnostics.Process()
    process1.StartInfo.WorkingDirectory = Request.MapPath("~/")
    process1.StartInfo.FileName = Request.MapPath("App.exe")
    process1.Start()
End Sub

It works perfectly on localhost. But when I upload and click the button, NOTHING HAPPENS!!
The page just sits. No error. The exe doesn't show up. Nothing!!

Probably have been asked before but I didn't find any solution. Please help guys.

You can't run any software like this in the website. The program probably started on the server and that's where it showed up (if you even have sufficient privileges for doing that).

Not sure what kind of software is that you're trying to run, but you have to convert it to be a web application instead.

When you use process.start it will start the new process rom the context of the process it was started from. In asp.net this will be the web server. When you are debugging from Visual Studio you are probably using the development webserver, which runs under your user account. When run on a "real" web server it will be run under IIS as a service. IIS runs by default under a restricted permission account that is not allowed to interact with the desktop at all. The application MAY be running as a background process, but won't be allowed to show a UI.

Your best bet to get this working is to have a separate process on the web server that polls either a database or a file on the system something that triggers the executable to run. You can pass arguments and other options through the file.

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