我有一个启动远程IE的代码。我希望以“以管理员身份运行”选项启动应用程序。
如何实现这一目标?
private static void StartSession(string hostName)
{
var filespec = Path.Combine(GetRootFolderSpec(), "session.rdp");
if (File.Exists(filespec)) File.Delete(filespec);
var settings = GetRdpSettings(hostName);
File.WriteAllText(filespec, settings);
File.SetAttributes(filespec, FileAttributes.Hidden);
Process.Start(filespec);
}
private static string GetRdpSettings(string hostName)
{
return @"redirectclipboard:i:1
redirectposdevices:i:0
redirectprinters:i:0
redirectcomports:i:1
redirectsmartcards:i:0
devicestoredirect:s:
drivestoredirect:s:
session bpp:i:32
prompt for credentials on client:i:1
span monitors:i:1
use multimon:i:1
remoteapplicationmode:i:1
server port:i:1111
allow font smoothing:i:1
screen mode id:i:1
smart sizing:i:1
promptcredentialonce:i:1
authentication level:i:2
gatewayusagemethod:i:2
gatewayprofileusagemethod:i:0
gatewaycredentialssource:i:0
full address:s:" + hostName + @"
alternate shell:s:||iexplore
remoteapplicationprogram:s:||iexplore
gatewayhostname:s:
remoteapplicationname:s:iexplore.exe
remoteapplicationcmdline:s:";
}
答案 0 :(得分:0)
如果您在Windows或以上版本上运行
if (Environment.OSVersion.Version.Major >= 6)
{
processStartInfo.Verb = "runas";
}