setupcomplete cmd что это
добавление пользовательского скрипта в программа установки Windows
сценарии установки Windows
Запуск скрипта после завершения установки (SetupComplete. cmd)
Порядок операций
после установки Windows, но до появления экрана входа программа установки Windows выполняет поиск файла SetupComplete. cmd в каталоге %виндир%\сетуп\скриптс\
Программа установки не проверяет коды выхода или уровни ошибок в скрипте после выполнения команды Setupcomplete. cmd.
Невозможно перезагрузить систему и возобновить выполнение Setupcomplete. cmd. Не следует перезагружать систему, добавляя команду, например shutdown-r. Система будет переведена в неисправное состояние.
выполнение скрипта, если программа установки Windows обнаруживает неустранимую ошибку (ErrorHandler. cmd)
ErrorHandler. cmd полезен при одновременной установке множества систем. это помогает обнаружить возникновение ошибки во время программа установки Windows. В этом случае программа установки автоматически запускает сценарий, который может содержать настраиваемые команды или действия для устранения причины ошибки.
если программа установки Windows обнаружит неустранимую ошибку и не сможет завершить установку, программа установки Windows ищет командный сценарий в следующем каталоге: %виндир%\сетуп\скриптс\еррорхандлер.кмд. В зависимости от того, найден ли скрипт, будет выполнено одно из двух действий.
в зависимости от этапа программа установки Windows компьютер вернется к среде, из которой выполнялся программа установки Windows, например в более ранней версии операционной системы или среда предустановки Windows (Windows PE).
могут возникнуть экземпляры, когда программа установки Windows встречает более одной ошибки и несколько раз запускает скрипт ErrorHandler. cmd. При разработке кода для ErrorHandler. cmdубедитесь, что этот сценарий можно запустить несколько раз.
Использование ErrorHandler. cmd
Чтобы использовать ErrorHandler. cmd, можно выполнить одно из следующих действий.
Подключите образ и добавьте его к образу в %виндир%\сетуп\скриптс\еррорхандлер.КМД. Отключите образ.
Запуск скриптов с помощью программы Unattend
создайте файл Unattend.xml с одним из этих параметров для запуска во время процесса программа установки Windows. Его можно использовать с ключами продукта OEM.
Чтобы запустить службы или команды, которые могут запускаться одновременно, используйте Рунасинчронаускоммандс.
Некоторые из этих параметров выполняются в контексте пользователя, а другие выполняются в контексте системы в зависимости от этапа настройки.
Эти сценарии следует использовать экономно, так как длинные скрипты могут помешать пользователю быстро достичь начального экрана. для розничных версий Windows к этим сценариям применяются дополнительные ограничения. Дополнительные сведения см. в руководстве по лицензированию и политикам в центре партнеров OEM.
При добавлении сценария с помощью фирстлогонкоммандс он активируется при следующей загрузке, даже если вы перейдете в режим аудита, нажав клавиши CTRL SHIFT F3. чтобы выполнить загрузку в режиме аудита без запуска этих сценариев, добавьте параметр: Microsoft-Windows-деплоймент\ресеал\mode = audit.
SetupComplete.cmd
Программа установки Windows Vista спроектирована таким образом, что в конце установки она ищет в папке %WINDIR%\Setup\Scripts файл SetupComplete.cmd. Если таковой находится, все внесенные в него команды выполняются автоматически до первого входа пользователя в систему. Причем выполняются они от имени системной учетной записи LocalSystem.
Важно! В Windows 10 файл не отрабатывает при использовании ключей продукта ОЕМ (документация). В этом случае используйте FirstLogonCommands.
В папке $OEM$ нужно создать папку $$, затем в папке $$ создать папку Setup и, наконец, в папке Setup создать папку Scripts. В папке Scripts размещается файл SetupComplete.cmd, в который вносятся необходимые вам команды. В итоге должна получиться такая структура:
Как уже было сказано выше, команды в файле могут быть различными. Ниже приводится несколько таких команд.
Add a Custom Script to Windows Setup
Windows setup scripts
Setupcomplete.cmd and ErrorHandler.cmd are custom scripts that run during or after the Windows Setup process. They can be used to install applications or run other tasks by using cscript/wscript scripts.
Run a script after setup is complete (SetupComplete.cmd)
Order of operations
After Windows is installed but before the logon screen appears, WindowsВ Setup searches for the SetupComplete.cmd file in the %WINDIR%\Setup\Scripts\ directory.
If a SetupComplete.cmd file is found, Windows Setup runs the script. WindowsВ Setup logs the action in the C:\Windows\Panther\UnattendGC\Setupact.log file.
Setup does not verify any exit codes or error levels in the script after it executes SetupComplete.cmd.
If the computer joins a domain during installation, the Group Policy that is defined in the domain is not applied to the computer until Setupcomplete.cmd is finished. This is to make sure that the Group Policy configuration activity does not interfere with the script.
Run a script if WindowsВ Setup encounters a fatal error (ErrorHandler.cmd)
ErrorHandler.cmd is useful when you’re installing many systems at the same time. This helps you detect when an error occurs during WindowsВ Setup. When it does, Setup automatically runs a script that can contain custom commands or actions to address the cause of the error.
If WindowsВ Setup encounters a fatal error and is prevented from completing the installation, WindowsВ Setup searches for a command script in the following directory: %WINDIR%\Setup\Scripts\ErrorHandler.cmd. One of two actions will occur, depending on whether the script is found.
Depending on the phase of WindowsВ Setup, the computer will return to the environment from which WindowsВ Setup was executed, such as an earlier version of the operating system or Windows Preinstallation Environment (WindowsВ PE), for example.
There may be instances when WindowsВ Setup encounters more than one error and runs the ErrorHandler.cmd script more than once. When developing the code for ErrorHandler.cmd, make sure that you can run this script multiple times.
Use ErrorHandler.cmd
To use ErrorHandler.cmd, you can do either of the following:
Mount the image, and add it to the image, in %WINDIR%\Setup\Scripts\ErrorHandler.cmd. Unmount the image.
Add ErrorHandler.cmd to a temporary file location (for example, C:\Temp\ErrorHandler.cmd), and then run Windows Setup using the /m option.
Use Unattend to run scripts
Create an Unattend.xml file with one of these settings to run during the Windows Setup process. This can be used with OEM product keys.
To run services or commands that can start at the same time, use RunAsynchronousCommands.
Some of these settings run in the user context, others run in the system context depending on the configuration pass.
Add Microsoft-Windows-Setup\RunAsynchronousCommand or RunSynchronousCommand to run a script as Windows Setup starts. This can be helpful for setting hard disk partitions.
Add Microsoft-Windows-Deployment\RunAsynchronousCommand or RunSynchronousCommand to the auditUser configuration pass to run a script that runs when the PC enters audit mode. This can be helpful for tasks like automated app installation or testing.
Add Microsoft-Windows-Shell-Setup\LogonCommands\AsynchronousCommand or FirstLogonCommands\SynchronousCommand to run after the Out of Box Experience (OOBE) but before the user sees the desktop. This can be especially useful to set up language-specific apps or content after the user has already selected their language.
Use these scripts sparingly because long scripts can prevent the user from reaching the Start screen quickly. For retail versions of Windows, additional restrictions apply to these scripts. For info, see the Licensing and Policy guidance on the OEM Partner Center.
When you add a script using FirstLogonCommands, it will be triggered on the next boot, even if you boot into audit mode using Ctrl+Shift+F3. To boot to audit mode without triggering these scripts, add the setting: Microsoft-Windows-Deployment\Reseal\Mode = Audit.
Setupcomplete cmd что это
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 or above | No |
setupconfig.ini files used for feature updates | No |
Remarks
The default value for is 1. specifies the baud to use when Windows transfers data during debugging. The default value is 19200, but can also be set to 57600 or 115200.
/AddBootMgrLast
Instructs Windows Setup to add the Windows Boot Manager as the last entry in the UEFI firmware boot order.
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 and above | No |
setupconfig.ini files used for feature updates | No |
Remarks
This option is only supported on UEFI PCs running Windows PE 4.0 or later.
Performs an automated upgrade to a newer version of Windows.
Parameter | Description |
---|---|
Clean | Performs a clean install of Windows |
DataOnly | Performs an upgrade of Windows, saving only data (and not apps.) If the data-only installation option is not available due to compatibility checks, Windows Setup will exit silently and log an exit code. |
Upgrade | Performs an upgrade of Windows saving apps and data. If the upgrade installation option is not available, or the user needs to resolve an app compatibility issue, Windows Setup will exit silently and log an exit code. |
NoAutoEit | Not used starting in Windows 10. In Windows 8.1, if an error is found, Windows Setup does not exit, but instead stops and stays on the Windows Setup screen until the user addresses the issue. The installation from that point on is attended. |
PerformDU | Not used starting in Windows 10. In Windows 8.1, Windows Setup checks for Dynamic Updates for Windows Setup |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | No |
Remarks
When /Auto is used, an unattend file cannot be used. When /Auto is used, Windows Setup consumes ei.cfg, and checks compatibility issues before starting the installation. If ei.cfg is malformed, Windows Setup exits silently and logs an exit code. See Windows Setup Exit Codes below. When /Auto is used, only the following customizations of the Windows image are supported. This is not a change in Windows Setup support policy but instead a clarification:
For clarity, when /Auto is used, Windows Setup does not support upgrades nor clean installs to a Windows image that has been customized by adding / removing / changing applications, settings nor drivers.
When /Auto is used, Windows Setup will upgrade using the \sources\install.wim Windows image. Using Dism /Export-Image, this image can be used as a source image for exporting a new image using the /Compress:recovery option. This exported image must be named install.esd for Windows Setup to use it instead of install.wim. You must also remove install.wim from \sources. You should only export to install.esd if you want to reduce the Windows image size. The exported image will be smaller, but will not be mountable.
Starting with Windows 11, /Auto will not accept nor surpress the end user license agreement. See /EULA.
/BitLocker
Specifies the BitLocker status during upgrades.
Parameter | Description |
---|---|
AlwaysSuspend | BitLocker is always suspended during an upgrade. |
TryKeepActive | Attempts an upgrade without suspending BitLocker. If the upgrade fails, Windows Setup will suspend BitLocker and complete the upgrade. This is the default behavior if the /BitLocker option is not specified. |
ForceKeepActive | Enables upgrading without suspending BitLocker. If the upgrade can’t be completed because BitLocker is active, the upgrade will fail. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
/BusParams
Specifies the PCI address of a 1394, USB, or NET debug port.
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 or above | No |
setupconfig.ini files used for feature updates | No |
Remarks
The bus, device, and function numbers must be in decimal format. For more information, see Setting Up Kernel Debugging with USB 2.0.
/ConfigFile
Specifies the location to the setupconfig file.
Parameter | Description |
---|---|
Local file path or UNC network path to a folder that contains the Windows Setup configuration file. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | No |
Remarks
If you include an option on the command line and the same option in the setupconfig file, the setupconfig file option and value has precedence.
/CompactOS
Specifies whether to use the Compact OS feature to save hard drive space.
Parameter | Description |
---|---|
Enable | Windows Setup installs Windows using compressed system files. |
Disable | Windows Setup installs Windows using uncompressed system files. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
Remarks
By default, Windows Setup determines whether to use this feature automatically. To learn more about Compact OS, see Compact OS, single-instancing, and image optimization.
/Compat
Instructs Windows Setup how to handle compatibility scans and messages.
Parameter | Description |
---|---|
IgnoreWarning | Windows Setup completes installation, ignoring any dismissible compatibility messages. |
ScanOnly | Windows Setup runs through compatibility scans, and then exits (without completing the installation) with an exit code to indicate if any compatibility concerns are present. Windows Setup will return 0xC1900210 if no concerns are found. Windows Setup will return 0xC1900208 if compatibility concerns are found. |
This command works with other switches. To run Windows Setup in the background without any UI:
To ignore common disclaimers in the UI, for example, language changes:
Often an IT Pro will look at the compat XML if Windows Setup finds compatibility issues. Use /CopyLogs to collect Windows Setup logs:
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes only with /Compat IgnoreWarning |
Remarks
This option is available starting in Windows 10 and above.
If you launch Windows Setup with /Compat ScanOnly:
/CopyLogs
Windows Setup will copy or upload compressed logs upon failure to the specified location assuming machine/user has permission and network access to location.
Parameter | Description |
---|---|
Local file path or UNC network paths. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
Remarks
Accepted parameters are local file paths and UNC network paths. Execution runs in the system context, so it may not have permissions to copy to locations that require user permissions.
/Debug
Enables kernel debugging over a communications (COM) port when Windows is running, and during the WindowsPE configuration pass of Windows Setup.
Parameter | Description |
---|---|
Specifies the debugging port. The default value is 1. | |
Specifies the baud to use when Windows transfers data during debugging. The default setting is 19200, but can also be set to 57600 or 115200. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 or above | No |
setupconfig.ini files used for feature updates | No |
/DiagnosticPrompt
Specifies that the Command Prompt is available during Windows Setup.
Parameter | Description |
---|---|
Enable | The Command Prompt can be accessed by pressing Shift+F10 during Windows Setup. |
Disable | The Command Prompt is not available during Windows Setup. The Command Prompt wil not be available while offline and OOBE phases are running. This is the default setting. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
Remarks
This option is available starting in Windows 10, Version 1703.
/DynamicUpdate
Specifies whether Windows Setup will perform Dynamic Update operations (search, download, and install updates).
Parameter | Description |
---|---|
Enable | Dynamic Update operations are performed. |
Disable | Dynamic Update operations are not performed. |
NoDrivers | Dynamic Update operations are performed except driver acquisition. |
NoDriversNoLCU | Dynamic Update operations are performed except driver and latest cumulative update acquisition. |
NoLCU | Dynamic Update operations are performed except latest cumulative update acquisition. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes for Microsoft Update (MU) based feature updates; Yes for Unified Updated Platform (UUP) based feature updates only when /DynamicUpdate NoDrivers is specified |
Remarks
NoDrivers, NoLCU and NoDriversNoLCU are new for Windows 10, version 2004. When NoDrivers, NoLCU or NoDriversNoLCU is specified, Dynamic Update operations will be performed but drivers and/or the latest cumulative update acquisition will not be performed. /DynamicUpdate can be used with /SkipFinalize to control Dynamic Update operations; /DynamicUpdate is ignored when used with /Finalize.
/EMSPort
Enables or disables Emergency Management Services (EMS) during Windows Setup and after the server operating system has been installed.
Parameter | Description |
---|---|
COM1 | Enables EMS over COM1. Supported for x86 systems only. |
COM2 | Enables EMS over COM2. Supported for x86 systems only. |
UseBIOSSettings | uses the setting that the BIOS specifies. For x86 systems, Windows uses the value from the Serial Port Console Redirection (SPCR) table. If no SPCR table or EFI console device path is specified in the BIOS, Windows disables EMS. |
Off | Disables EMS. If EMS is disabled in Windows Setup, you can later enable EMS by modifying the boot settings. |
Specifies the baud to use when Windows transfers data during debugging. The default value is 19200, but it can also be set to 57600 or 115200. |
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 or above | No |
setupconfig.ini files used for feature updates | No |
Instructions Windows Setup to suppress the Windows Setup end user license agreement user experience.
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
Remarks
This option is new starting with Windows 11. Specifying /EULA accept instructs Windows Setup that the end user license agreement has been accepted. Starting with Windows 11, acceptance of the Windows EULA is required before Windows Setup installation begins. By specifying /EULA accept you are agreeing that when applying this operating system either (1) the applicable Windows license was purchased though volume licensing, or (2) that you are accepting the relevant Microsoft Software License Terms. Windows Setup will return error MOSETUP_E_EULA_ACCEPT_REQUIRED (0xC190010E) if /EULA accept is not specified and (1) /Quiet is specified, or (2) if Windows Setup is started where user interaction is not supported. To learn more about licensing, see Microsoft License Terms.
/Finalize
Instructions Windows Setup to finish previously started update operations on the down-level OS, followed by an immediate reboot to start the offline phase.
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | No |
Remarks
This option is new for Windows 10, version 2004. /Finalize should not be specified with the /NoReboot option. Windows Setup will return error MOSETUP_E_FINALIZE_RESUME_FAILURE (0xC1900132) if /Finalize is called and the device is not in the proper state to resume after running /SkipFinalize. See /SkipFinalize.
/ImageIndex
Instructions Windows Setup which OS image to install from install.wim if multiple images may be applicable.
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | Yes |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes for Microsoft Update (MU) based feature updates; No for Unified Updated Platform (UUP) based feature updates |
Remarks
If multiple images are applicable, Windows Setup will prompt the user to select. If multiple images are applicable and Windows Setup is invoked with /Quiet, Windows Setup will fail with error MOSETUP_E_NO_MATCHING_INSTALL_IMAGE (0xC1900215). This may occur when the product key specified using /PKey applies to multiple OS images.
/InstallDrivers
Configuration | Applicable |
---|---|
Setup.exe started from WinPE | No |
Setup.exe started from Windows 10 or above | Yes |
setupconfig.ini files used for feature updates | Yes |
/InstallFrom
Specifies a different Install.wim file to use during Windows Setup.
Parameter | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This option also be used with split image files (.swm). Select the first split image file in the series
Remarks /InstallLangPacksAdds language packs (lp.cab) to the new Windows 10 or above installation.
Instructs Windows Setup to copy alternate files from an alternate location. This option instructs Windows Setup to look in the alternate location first, and, if files are present, to use them instead of the files from the default location.
Examples If you change resources in your replacement files, you must add the updated Multilanguage User Interface (MUI) files to the installation.
/MigNEOTells Windows Setup to perform an upgrade of Windows without additional offline phase optimizations.
Remarks /MigrateDriversInstructs Windows Setup whether to migrate the drivers from the existing installation during the upgrade.
Remarks /NetDebugEnables kernel debugging over the network.
Remarks /NoRebootInstructs Windows Setup not to restart the computer after the down-level phase of Windows Setup completes.
Remarks Supplies Windows Setup with the specific product key.
Remarks /PriorityTells Windows Setup to increase the thread priority from low to normal for feature updates through Windows Update.
Remarks /PostOOBEAfter Windows Setup is complete, run a script. Syntax
BT to be run after OOBE.
Remarks /PostRollbackInstructs Windows Setup to run a script if the feature update fails to install and rolls back the changes, or if the user chooses to uninstall the feature update and go back to a previous version of Windows. Syntax
BT to be run after OOBE. /QuietThis will suppress any Windows Setup user experience including the rollback user experience.
Remarks /ReflectDriversSpecifies the path to a folder that contains encryption drivers for a computer that has third-party encryption enabled.
Remarks /ResizeRecoveryPartitionSpecifies whether it’s OK to resize the existing Windows Recovery Environment (Windows RE) partition or create a new one during installation.
/ShowOOBESpecifies whether the user is required to interactively complete the out of box experience (OOBE).
Remarks /SkipFinalizeInstructions setup to start update operations on the down-level OS without initiating a reboot to start the offline phase.
Remarks /TelemetrySpecifies whether Windows Setup should capture and report installation data.
/TempDriveInstructs Windows Setup to put temporary installation files on the specified partition.
Remarks /UnattendEnables you to use an answer file with Windows Setup.
Remarks /UninstallDetermines whether Windows will include controls that allow the user to go back to the previous operating system.
Remarks /USBDebugSets up debugging on a USB port.
Remarks /WDSDiscoverSpecifies that the Windows Deployment Services (WDS) client should be in discover mode. Examples
Remarks /WDSServerSpecifies the name of the Windows Deployment Services (WDS) server that the client should connect to.
Examples
Remarks
|