开发者

Running an .exe from a website

I've created an exe file that does some maintainance work on my server. I want to be able to launch it from the website that sits on the server. The exe has to be launched on the server itself and not on the clie开发者_如何学Gont.

My instincts tell me it's not possible but I've had to check with you guys.

If I need to set certain permissions / security - I can.


Yes, it can be done, but it's not recommended.

An ideal solution for running maintenance scripts/executables is to schedule them using cron on Unix/Linux systems or using Scheduled Tasks in Windows. Some advantages of the automated approach vs. remote manual launch:

  • The server computer is self-maintaining. Clients can fail and people can forget. As long as the server is running the server will be keeping itself up to date, regardless of the status of client machines or persons.
  • When will the executable be launched? Every time a certain page is visited? What if the page is refreshed? For a resource-intensive script/executable this can severely degrade server performance. You'll need to code rules to handle multiple requests and monitor running maintenance processes. Cron & scheduled tasks handle these possibilities already.


A very crude option, Assuming IIS: Change Execute Access from "Scripts Only" or "None" to "Scripts and Executables"

To make this less crude, you should have the executable implement a CGI interface (if that is under your control.

And, if you want to use ASP.NET to add autorization/authentication, the code (C#) to do this would be:

System.Diagnostics.Process process;

var startInfo = New System.Diagnostics.ProcessStartInfo("C:\file.exe")

process.StartInfo = startInfo;
process.Start();
process.WaitForExit();


It's possible, but almost certainly it's a bad idea. What environment/webserver? You should just need to set the relevant 'execute' permissions for the file.

I really suggest that you don't do this, however, and configure the task to run automatically in the background. The reasoning is that, configured badly, you could end up letting people run any executable, and depending on other factors, completely take over your machine.


Depends what language you're using; most server side scripting languages give you a way to exectue shell commands, for example:

$result=`wc -l /etc/passwd`;

executed a unix command from perl.


Most web languages (I know at least Java and PHP) allow you to execute a command line argument from within a program.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜