且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用管理员帐户的asp.net运行程序

更新时间:2023-12-02 16:10:16

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

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();