how I can run any .exe file through WebService that I build ?
我如何通过我构建的WebService运行任何.exe文件?
thank's in advance
提前致谢
3 个解决方案
#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.
我建议遵循以下顺序。
- 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)
- 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)
- 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).
(可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)
使用Process.Start启动临时文件并等待它停止运行(可能提供一个参数来等待退出)
删除临时文件。
报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。
接收文件并将其写入临时目录。 (可选)使用防病毒扫描程序扫描文件。 (取决于您的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.
我建议遵循以下顺序。
- 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)
- 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)
- 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).
(可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)
使用Process.Start启动临时文件并等待它停止运行(可能提供一个参数来等待退出)
删除临时文件。
报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。
接收文件并将其写入临时目录。 (可选)使用防病毒扫描程序扫描文件。 (取决于您的Web服务的信任级别)使用Process.Start启动临时文件并等待它停止运行(可能提供一个等待退出的参数)删除临时文件。报告执行结果(如果它是控制台应用程序,您甚至可以报告应用程序打印的文本)。