使用管理员帐户的asp.net运行程序 [英] asp.net run program with Administrator account

查看:121
本文介绍了使用管理员帐户的asp.net运行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用管理员帐户并启用桌面交互功能,从ASP.NET应用程序中运行一个控制台应用程序.我在下面尝试了代码,控制台应用程序可以正常运行,但在NETWORK SERVICE帐户内.有任何想法如何在管理员帐户下运行控制台吗?

I need to run one console application from ASP.NET application using Administrator account and with Desktop interaction enabled. I have tried code below, console app runs ok but within NETWORK SERVICE account. Any ideas how to run console under Administrator account?

    string enginePath = Server.MapPath(@"~/engine/MyConsole.exe");
    System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(enginePath, "");
    System.Diagnostics.Process p = System.Diagnostics.Process.Start(info);            
    p.WaitForExit();

关于, 托马斯

推荐答案

您可以使用清单文件并将其内置到控制台应用程序中,该文件将指示清单文件始终在管理员帐户下运行.请参见此示例.

You can use a manifest file and built it into your console application that will instruct it to always run under an admin account. See this example.

如果这不适用于您,则可以尝试在

If this doesn't work for you then you could try passing in Admin account credentials in the ProcessStartInfo property e.g.

string enginePath = Server.MapPath(@"~/engine/MyConsole.exe");
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(enginePath, "");
info.UserName = "Administrator";
info.Password = "Password";
System.Diagnostics.Process p = System.Diagnostics.Process.Start(info);                p.WaitForExit(); 

这篇关于使用管理员帐户的asp.net运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆