2

我需要在 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 中运行代码,它可以在命令行窗口中手动执行)

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

4

1 回答 1

1

您应该参考 Wage Wegner 的本指南。它处理的是Expression Encoder,但是Desktop Experience的前提是完全一样的:

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
于 2011-03-03T13:01:51.303 回答