我如何通过WebService运行任何.exe文件

时间:2022-02-16 16:02:34

how I can run any .exe file through WebService that I build ?

我如何通过我构建的WebService运行任何.exe文件?

thank's in advance

提前致谢

3 个解决方案

#1


Take a look at the System.Diagnostics.Process class.

看一下System.Diagnostics.Process类。

#2


You can try this.

你可以试试这个。

using System.Diagnostics;

class Program
{
    static void Main()
    {
        Process.Start("example.exe");
    }
}

#3


I think you want to be able to send a exe file to your webservice and than execute that?

我想你希望能够将exe文件发送到你的web服务而不是执行它?

I would advice to following sequence.

我建议遵循以下顺序。

  1. Recieve the file and write it to a temporary directory.
    • Optionally scan the file with a anti-virus scanner. (Depending on the level of trust of your webservice)
    • (可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)

    • Use Process.Start to start the temporary file and wait for it to stop running (perhaps supply a parameter to wait for exit or not)
    • 使用Process.Start启动临时文件并等待它停止运行(可能提供一个参数来等待退出)

    • Delete the temporary file.
    • 删除临时文件。

    • Report back the result of the execution (if it's console application you could even report back the text printed by the application).
    • 报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。

  2. 接收文件并将其写入临时目录。 (可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)使用Process.Start启动临时文件并等待它停止运行(可能提供一个等待退出的参数)删除临时文件。报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。

#1


Take a look at the System.Diagnostics.Process class.

看一下System.Diagnostics.Process类。

#2


You can try this.

你可以试试这个。

using System.Diagnostics;

class Program
{
    static void Main()
    {
        Process.Start("example.exe");
    }
}

#3


I think you want to be able to send a exe file to your webservice and than execute that?

我想你希望能够将exe文件发送到你的web服务而不是执行它?

I would advice to following sequence.

我建议遵循以下顺序。

  1. Recieve the file and write it to a temporary directory.
    • Optionally scan the file with a anti-virus scanner. (Depending on the level of trust of your webservice)
    • (可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)

    • Use Process.Start to start the temporary file and wait for it to stop running (perhaps supply a parameter to wait for exit or not)
    • 使用Process.Start启动临时文件并等待它停止运行(可能提供一个参数来等待退出)

    • Delete the temporary file.
    • 删除临时文件。

    • Report back the result of the execution (if it's console application you could even report back the text printed by the application).
    • 报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。

  2. 接收文件并将其写入临时目录。 (可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)使用Process.Start启动临时文件并等待它停止运行(可能提供一个等待退出的参数)删除临时文件。报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。