azure - 如何在 Azure 中静默/自动安装桌面体验?

标签 azure azure-worker-roles

我需要在 Azure 辅助角色中安装桌面体验。通过命令行安装 DE 可以通过:

c:\servermanagercmd -install Desktop-Experience

然后需要重新启动。

如何才能最好地在 Azure 辅助角色中实现此功能?

<小时/>

更新:

1) 确保使用操作系统系列 2 和 SDK >=1.3

2) 使用提升的启动任务通过以下命令调用包含的批处理文件:

3) servermanagercmd -install Desktop-Experience -restart -resultPath results.xml
<小时/>

我已经尝试过

a) 将该命令行放入批处理/.cmd 文件中,并通过提升的启动任务运行它。结果:辅助角色保持中止并在永无休止的循环中重新启动。

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

InstallDesktopExperience.cmd:

servermanagercmd -install Desktop-Experience

重新启动.cmd:

shutdown /r

结果是 Azure 辅助角色中的事件查看器显示来自 TrustedInstaller 的异常 (0xc0000005)。事件日志中显示此错误后,也无法通过打开命令行窗口并键入命令来手动安装 DE。我收到错误:

错误:[桌面体验]安装失败。尝试安装桌面体验失败,错误代码为 0x80080005。服务器执行失败(HRESULT 异常:0x80080005 (CO_E_SERVER_EXEC_FAILURE))

(但如果我没有在 OnStart 中运行代码,则可以在命令行窗口中手动执行此操作)

我迷路了。预先感谢您的任何和所有建议。

最佳答案

您应该引用 Wage Wegner 的本指南。它涉及表达式编码器,但桌面体验的先决条件完全相同:

http://www.wadewegner.com/2011/01/using-expression-encoder-4-in-a-windows-azure-worker-role/

<小时/>

来自相同的片段,但您应该花时间阅读他对其中一些概念的解释

REM : Install the Desktop Experience
ServerManagerCMD.exe -install Desktop-Experience -restart -resultPath results.xml
REM : Make a folder for the AppData
md "%~dp0appdata"
REM : Change the location of the Local AppData
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
REM : Install Encoder
"%~dp0\webpicmd\WebPICmdLine.exe" /accepteula /Products: ExpressionEncoder4 /log:encoder.txt
REM : Change the location of the Local AppData back to default
reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f
REM : Exit gracefully
exit /b 0

关于azure - 如何在 Azure 中静默/自动安装桌面体验?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5176812/

相关文章:

Azure SQL 升级/降级

wordpress - 将带有数据库的 WordPress 站点迁移到 Windows Azure

.net - 防止未处理的异常破坏 Azure 辅助角色

c# - 我不想直接输入应用程序洞察的 key 来注册日志

powershell - Powershell : Run Login-AzureRmAccount to login

azure - Windows azure 通知中心设备注册 native 与模板

azure - 在 Azure VM 上访问互联网

c# - 从 Azure 上运行的辅助角色服务访问 Sharepoint

Azure辅助角色配置

azure - 对于 Azure 项目,在管理多个服务配置时,当前配置选择保存在哪里