从网站运行 .exe

发布于 2024-08-18 07:11:34 字数 152 浏览 5 评论 0原文

我创建了一个 exe 文件,它在我的服务器上执行一些维护工作。 我希望能够从服务器上的网站启动它。 该 exe 必须在服务器本身上启动,而不是在客户端上启动。

我的直觉告诉我这是不可能的,但我必须和你们核实一下。

如果我需要设置某些权限/安全性 - 我可以。

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

傲性难收 2024-08-25 07:11:34

是的,可以这样做,但不建议这样做。

运行维护脚本/可执行文件的理想解决方案是在 Unix/Linux 系统上使用 cron 或在 Windows 中使用计划任务来安排它们。与远程手动启动相比,自动化方法的一些优点:

  • 服务器计算机是自我维护的。客户可能会失败,人们也可能会忘记。只要服务器正在运行,无论客户端计算机或人员的状态如何,服务器都会保持自身最新状态。
  • 可执行文件何时启动?每次访问某个页面时?如果页面刷新了怎么办?对于资源密集型脚本/可执行文件,这可能会严重降低服务器性能。您需要编写规则来处理多个请求并监视正在运行的维护流程。克罗恩 &计划任务已经处理了这些可能性。

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.
千仐 2024-08-25 07:11:34

一个非常粗略的选项,假设 IIS:将执行访问从“仅脚本”或“无”更改为“脚本和可执行文件”

为了使这个不那么粗略,您应该让可执行文件实现 CGI 接口(如果它在您的控制之下)

。 ,如果您想使用 ASP.NET 添加授权/身份验证,则执行此操作的代码 (C#) 为:

System.Diagnostics.Process process;

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

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

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();
梦在夏天 2024-08-25 07:11:34

这是可能的,但几乎可以肯定这是一个坏主意。什么环境/网络服务器?您应该只需要为该文件设置相关的“执行”权限。

不过,我真的建议您不要这样做,并将任务配置为在后台自动运行。原因是,如果配置不当,您最终可能会让人们运行任何可执行文件,并根据其他因素完全接管您的计算机。

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.

A君 2024-08-25 07:11:34

取决于您使用的语言;大多数服务器端脚本语言都为您提供了执行 shell 命令的方法,例如:

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

从 perl 执行 unix 命令。

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.

梦回旧景 2024-08-25 07:11:34

大多数网络语言(我至少知道 Java 和 PHP)允许您从程序内执行命令行参数。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文