• Image Management Service

  1. Help Center
  2. Image Management Service
  3. User Guide
  4. Creating a Private Image
  5. Creating a System Disk Image Using a Windows ECS
  6. (Optional) Running Sysprep

(Optional) Running Sysprep


Run Sysprep to ensure that the SID is unique after the ECS is added to the domain.

After installing Cloudbase-Init, you need to check whether the ECS needs to be added to a domain or its SID is unique.

  • If yes, perform the operations in this section to run Sysprep.
  • If no, the installation is complete.


  • Run Sysprep as the administrator.
  • Before running Sysprep, ensure that Windows is activated.
  • For a newly activated Windows ECS, you can run Sysprep only once at a time.
  • If the ECS is created from an image file, only Sysprep provided by the image file can be used. In addition, Sysprep must always reside in the %WINDIR%\system32\sysprep directory.
  • Windows must be in the activated state, and the remaining Windows rearm count must be greater than or equal to 1. Otherwise, the Sysprep encapsulation cannot be executed.

    Run the following command in the Windows command line and check how many times you can run Sysprep in the displayed Windows Script Host dialog box:

    slmgr.vbs /dlv

    If the value of Remaining Windows rearm count is 0, you cannot run Sysprep any more.

    Figure 1 Windows Script Host


  1. Enter the directory where Cloudbase-Init is installed.

    C:\Program Files\Cloudbase Solutions\ is used as an example. Switch to the root directory of drive C and run the following command to enter the installation directory:

    cd C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf

  2. Run the following command to encapsulate Windows:

    C:\Windows\System32\sysprep\sysprep.exe /generalize /oobe /unattend:Unattend.xml

    • Ensure that /unattend:Unattend.xml is contained in the preceding command. Otherwise, the username, password, and other important configuration information of the ECS will be reset, and you must manually configure the OS when you use the image created from this ECS to create new ECSs.
    • After the command is executed, the ECS will stop automatically. After the ECS is stopped, you can use it to create an image to ensure that the SIDs of new ECSs created from this image are unique. If you restart the ECS, Sysprep will take effect only on this ECS. You need to run Sysprep again before creating an image.
    • After you have run Sysprep on an ECS running Windows Server 2012 or Windows Server 2012 R2, the password of the ECS administrator account will be deleted. You need to log in to the ECS and configure the password of the administrator account. After this, the ECS password configured on the management console will become invalid. Keep the new password secure.
    • If a domain account is required for logins, run Sysprep on the ECS before using it to create a private image. For details about the impact of running Sysprep, see Why Is Sysprep Required for Creating Private Images Using a Windows ECS?
    • The Cloudbase-Init account of a Windows ECS is an internal account of the Cloudbase-Init agent. This account is used for obtaining metadata and completing relevant configuration when the Windows ECS starts. If you modify or delete this account, or uninstall the Cloudbase-Init agent, you cannot inject initialized custom information into an ECS created using an image created from the ECS. Therefore, you are not advised to modify or delete the Cloudbase-Init account.
    Figure 2 Running Sysprep

  3. Create an image using the ECS after running Sysprep by referring to Creating a Windows Private Image.
  4. Use the image to create ECSs in batches. Each newly created ECS has a unique SID.

    Run the following command to query the SID:

    whoami /user

    Figure 3 SID before you run Sysprep

    Figure 4 SID after you run Sysprep