开发者

How do I run a command line process from a web application?

I want to run开发者_开发问答 a command line in ASP.NET 4.0 using C#. Actually I need to create a Web Service for doing this. How can I do that? I've read somewhere that when we run command line from Web, there can be some permission issues. If so, how can I overcome that?


using(var cmd= new Process())
{
            cmd.StartInfo.FileName   = "cmd.exe";
            cmd.StartInfo.Arguments = "";
            cmd.Start();
}

The process is started with the same credentials the web service process is running with. The default is LocalSystem or NetworkService. Those might not have the proper permissions to do whatever you plan to do.

Keep in mind that doing things like this is considered unsecure and bad practice.


Here you can take a look an example of class ProcessRunner that I created exactly for this purpose:

https://github.com/alexanderbeletsky/candidate.net/blob/master/Candidate.Core/System/ProcessRunner.cs

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜