我有密码:
// Execute msi
Process process = new Process();
process.StartInfo.FileName = "msiexec";
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(msiPath);
process.StartInfo.Arguments = $" /passive /i {Path.GetFileName(msiPath)}";
process.StartInfo.Verb = "runas";
process.StartInfo.UseShellExecute = true;
process.Start();
process.WaitForExit();
但我有错误:
此平台不支持UseShellExecute。
或者如果我禁用UseShellExecute
process.StartInfo.UseShellExecute = false;
由于管理权限,程序不执行
哇哦..。如何在UWP中作为管理员执行msi?
发布于 2021-07-09 07:58:48
首先,这里提到-如果您在UWP应用程序中这样做,设置ProcessStartInfo.UseShellExecute属性的ProcessStartInfo.UseShellExecute将引发PlatformNotSupportedException。你的行为是意料之中的。第二,UWP应用程序不支持Process.Start法。要从您的UWP应用程序运行exe文件,我建议您使用FullTrustProcessLauncher类。
首先,您需要复制exe文件并将其保存在UWP应用程序包中,例如资产文件夹。然后,请转到Manifest文件并添加runFullTrust受限功能.(App能力)。接下来,为UWP项目添加Windows扩展的引用。最后,您可以调用await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
从应用程序中启动exe文件。
https://stackoverflow.com/questions/68251943
复制相似问题