Office not Activating in App Layering (incl. MCS Image Prep OS Rearm Failed)

Office not Activating in App Layering (incl. MCS Image Prep OS Rearm Failed)

book

Article ID: CTX224900

calendar_today

Updated On:

Description

Due to the complexity of Microsoft licensing, App Layering utilizes our own set of scripts to ensure Windows & Office activation. These scripts are a part of the "Citrix App Layering OS Machine Tools," and their misconfiguration is the leading cause of the "Image Preparation OS Rearm Failed" error in App Layering environments.

This document covers the general approach to successfully activating Windows & Office in most App Layering 4.x environments. Specifically, this article is designed for environments that utilize KMS Licensing and non-generalized images (most provisioning methods, including MCS & PVS, require non-generalized images). 

If you have a more complex environment, or the issue persists after following this document, please refer to the Office Recipe, which is a 14 page documented covering the scripts in detail: 

Office Recipe: "How to Setup Office with App Layering" - https://support.citrix.com/article/CTX224566
 

Please note - Misconfigured activation scripts are not the only cause of the "Image Preparation OS Rearm Failed" error, and some alternate solutions are provided at the end of this article.

Image Preparation OS Rearm Failed

 


Instructions

===== Prerequisite: OS Layer - Add Version =====

1. Make sure you have downloaded the App Layering OS Machine Tools. You download these as part of a larger group of files when you download the full installation, but you can also download them as part of an upgrade or a standalone, zipped file from either the cloud site (https://layering.com.com/#/downloads) or the traditional downloads site (https://www.citrix.com/downloads/citrix-app-layering/)

Citrix Cloud Downloads


2. Running the machine tools (citrix_app_layering_os_machine_tools_4.6.0.exe) as an administrator is an important part of the process! We extract all of the machine tools into C:\Windows\Setup\Scripts. Note: Recommended procedure is to install and extract the tools on your OS layer itself. If you simply copy over previously extracted tools on a file share, the startup script will not be set correctly as a local GPO (see next step).
User-added image



3. When you run "citrix_app_layering_os_machine_tools_4.6.0.exe" kmssetup.cmd is configured as a startup script. You can verify that this local GPO is set correctly by running gpedit.msc, Local Computer Policy, Computer Configuration, Windows Settings, Scripts, Startup to verify it's in the list. Or by by checking this registry key: HKLM\Software\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0 - there should be one entry for kmssetup.cmd. If there is no entry, the easiest ways to set it is by re-extracting the scripts on this machine (step a), or by running C:\Windows\Setup\Scripts\kmsdir\gposetup.cmd. If there are two or more entries (sometimes caused by extracting the machine tools multiple times), delete the extra registry keys to run the script until there is only one remaining. Note: In Unidesk 2.x, 3.x, and generalized images, this GPO could also be configured via unattend.exe.

User-added image


4.Optional step: For increased performance later, you can compile .net assemblies now rather than at run time. In an elevated command line type

i.     cd..
ii.    cd Microsoft.Net\Framework\v4.0.30319
iii.   ngen eqi 3
iv.   cd..\..
v.    cd Framework64\v4.0.30319
vi.  ngen eqi 3

User-added image

 

5. Now, in C:\Windows\Setup\Scripts, run "SetKMSVersion.exe" as an administrator (this is one of the files extracted by the OS Machine Tools) and click 'Save Script.' Verify that this creates the "runipkato.cmd" file located in C:\Windows\Setup\scripts\kmsdir. This captures your OS version, and is necessary for license activation. If you do not rnu it as an administrator, you will run into issues, as the file will be saved on your desktop rather than where we want it (C:\Windows\Setup\Scripts\Kmsdir)

Customers generally prefer one of two ways to run these as administrator:
i. Open cmd.exe as administrator
ii. cd\windows\setup\scripts
iii. setkmsversion.hta
iv. "Save Script"
OR
i. Shift right click "setkmsversion.hta" in C:\windows\Setup\Scripts
ii. "Copy as Path"
iii. Open command prompt as administrator
iv. Paste the copied path, and run the command
 

User-added image



6. Reboot the machine for good measure, "Shutdown for Finalize" from the desktop, and "Finalize" the layer in the Management Console.



=====Office Application Layer=====
 

7. Now, install Office on a brand new application layer.

Note: Microsoft licensing is very interconnected! We recommend putting all Office components on the same Application layer. Please refer to the "Layering Strategy" section in document attached to this article for additional information on this topic (https://support.citrix.com/article/CTX224566)

Note: To avoid configuring settings specific to this machine, avoid opening or running any Office applications during packaging. 

User-added image


8. In C:\Windows\Setup\Scripts, run Optimize.hta (or Optimize64.exe in older versions) as an administrator. If you have previously run this, load your settings. You can tell if you have run this before by checking to see if the file "OfficeActivate.txt" exists in C:\Windows\Setup\Scripts\kmsdir. If not, it will be created after you save in step 10.

i. Open cmd.exe as administrator
ii. cd \Windows\Setup\Scripts
iii. Optimize.hta

User-added image


9. In section 'H' of Optimize.hta (or Optimize64.exe in older versions), check "Activate MS Office via KMS." Only select the product versions you have installed on this layer.
Note: "This scripting will only work if Office is installed in its default location. Additionally, it is not recommended to install more than one version of the same application on the same desktop.

Optimize64.exe

 

10. Click "Save settings A-J" - This will create flag files. One indicator that you have this step is a file titled "OfficeActivate.txt" in the \kmsdir\ folder, which tells the startup script (kmssetup.cmd) to run "OfficeActivate.cmd"

Save settings A-J of Optimize64.exe



11. If you are using any OS other than Windows 7 - run "Office2013Windows81_PREP.cmd" as an administrator. You guessed it - It's located in C:\Windows\Setup\Scripts.

Note: Do not let the outdated file name fool you - You must run this for all versions starting with Windows 8.1, and Office 2013 (You must run this for Office 2016, 365, Windows 10, etc)

i. Run cmd.exe as an administrator
ii. cd \Windows\Setup\Scripts
iii. Office2013Windows81_PREP.cmd

User-added image


12. Next you should run OSPPREAM.exe as an administrator to make sure the layer is properly prepped. This is only necessary if you opened up Office during the packaging/layering process (please do not do this), as it would save machine and user specific settings in the layer - which means all end users would have to "reconfigure" office at first launch. While not usually necessary to run this, we recommend it to be safe.

For Office 2016, the file is located in C:\Program Files\Microsoft Office\Office16

User-added image
 

13. Optional step: For later performance improvements, run another ngen update to compile assemblies - In command prompt as an administrator:

i.     cd..
ii.    cd Microsoft.Net\Framework\v4.0.30319
iii.   ngen update
iv.   cd..\..
v.    cd Framework64\v4.0.30319
vi.  ngen update

ngen .net update


14. Reboot for good measure, and then "Shutdown for Finalize." Then finalize the new app layer version in the Management Console.

 

=====If you are still seeing activation issues or the "Image Preparation OS Rearm Error" in MCS=====

Here are some other settings to check that may also affect Windows & Office Activation, or result in the MCS error

  • Check the status of the license; this will also show if you have rearmed too many times
    • Slmgr /dlv

 

  • Verify that you can manually activate
    • Slmgr /ato

 

  • Verify that the time is syncing properly. If the time zone doesn't sync with the KMS server, activation will fail.
    • Depending on how time sync is configured in your environment, you may need to join the platform layer to the domain
    • The "Windows Time" service is a Manual (Trigger Start) service - the trigger is joining the domain. Is your platform layer joined to the domain?
    • Once  the "Windows Time" service is running, command line "w32tm /query /peers" to check where time is being sync'd from
  • There have also been reports of this issue from cases where the MCS account does not have permissions because there is no entry in the local administrators group for domain admins (or whatever other group you use to manage local admins). 
    • Try using a GPP deployed to add Domain Admins to the Local Administrators group, and Domain Users to the Local Users Group. Plus typically your Citrix Users Group to the Local Direct Access Users Group if you want the Remote Desktop Users Group.
  • Verify that you can ping the KMS server

 

  • If you are using Activate Directory based activation, verify the machine is joined to the domain

 

  • If you still cannot activate manually, test each layer starting with the OS layer to determine why activation is failing. If you remove the Office layer, do you still see the same MCS error?
 
  • Additionally, you can disable the rearm option during MCS by renaming  "C:\ProgramFiles\Common Files\Microsoft 
    Shared\OfficeSoftwareProtectionPlatform\ospprearm.exe" (e.g. change .exe to .old), to avoid the process of MCS Rearming Office.
    • However, please ensure that Windows & Office are activating properly on the Virtual Machines created by MCS if you try this method.

Issue/Introduction

Windows & Microsoft Office 2010, 2013, 2016 KMS licensing is complex, and thus require customized scripts created by the App Layering team. Most commonly, these issues manifest themselves with unlicensed machines, or the MCS "Image Preparation OS Rearm Failed" error.

Additional Information

Office Recipe: https://support.citrix.com/article/CTX224566