我需要在 Azure Worker Role 中安装桌面体验。通过命令行安装 DE 可以通过以下方式完成:
c:\servermanagercmd -install Desktop-Experience
然后需要重新启动。
如何在 Azure Worker Role 中最好地完成这项工作?
更新:
1) 确保使用 OS Family 2 和 SDK >=1.3
2)使用提升的启动任务通过以下命令调用包含的批处理文件:
3) servermanagercmd -install Desktop-Experience -restart -resultPath results.xml
我努力了
a) 将该命令行放入批处理/.cmd 文件并通过提升的启动任务运行它。结果:worker 角色保持 Aborting 并在无休止的循环中重新启动。
b)我试图在 OnStart() 中创建一个新的 Process(),在提升的运行时,如下所示:
服务定义.csdef:
Runtime executionContext="elevated"
WorkerRole.cs:
public override bool OnStart()
{
if (!System.IO.File.Exists("Startup\\InstallationFinished.txt"))
{
Process startup = new Process();
startup.StartInfo.FileName = "Startup\\InstallDesktopExperience.cmd";
startup.StartInfo.CreateNoWindow = true;
startup.EnableRaisingEvents = true;
startup.Start();
startup.WaitForExit();
System.IO.File.WriteAllText("Startup\\InstallationFinished.txt",
"Installation is complete.");
startup.StartInfo.FileName = "Startup\\Reboot.cmd";
startup.Start();
}
base.OnStart();
}
安装DesktopExperience.cmd:
servermanagercmd -install Desktop-Experience
重启.cmd:
shutdown /r
结果是 Azure Worker Role 中的事件查看器显示来自 TrustedInstaller (0xc0000005) 的异常。在事件日志中显示此错误后,无法通过打开命令行窗口并键入命令手动安装 DE。我得到错误:
错误:[桌面体验] 安装失败。尝试安装桌面体验失败,错误代码为 0x80080005。服务器执行失败(来自 HRESULT 的异常:0x80080005 (CO_E_SERVER_EXEC_FAILURE))
(但如果我没有在 OnStart 中运行代码,它可以在命令行窗口中手动执行)
我迷路了。提前感谢您的任何和所有建议。