嘿,我正在尝试将我的Application.exe作为runas管理员启动,但仍然无法启动我已经尝试了两个动词=" runas"以及创建app.manifest文件,但我的exe不在管理员模式下打开。
我正在使用此代码:
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = GetASDeploymentExe(),
Arguments = GetASDeploymentCmdArgs(),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
Domain = "***",
UserName = username,
Password = secstr,
Verb = "runas"
}
};
proc.Start();
config.ASDeploymentToolPID = proc.Id;
string line = string.Empty;
do
{
line = proc.StandardOutput.ReadLine();
Console.WriteLine(line);
} while (!proc.HasExited);
string error = string.Empty;
while (!proc.StandardError.EndOfStream)
{
error = proc.StandardError.ReadLine();
Logger.WriteError(error);
}
}
答案 0 :(得分:-1)
试试这个:
//Vista or higher check
if (System.Environment.OSVersion.Version.Major >= 6)
{
p.StartInfo.Verb = "runas";
}