提供从命令行在 Windows Installer 上安装、修改和执行作的方法。
Install options
设置用于启动安装包的安装类型。
Syntax
msiexec.exe [/i][/a][/j{u|m|/g|/t}][/x] <path_to_package>
Parameters
Parameter | Description |
---|---|
/i | 指定正常安装。 |
/a | 指定管理安装。 |
/ju | 将产品播发给当前用户。 |
/jm | 将产品播发给所有用户。 |
/j/g | 指定播发包使用的语言标识符。 |
/j/t | 将转换应用于播发的包。 |
/x | 卸载包。 |
<path_to_package> |
指定安装包文件的位置和名称。 |
Examples
To install a package named example.msi from the C: drive, using a normal installation process, type:
msiexec.exe /i "C:\example.msi"
Display options
可以根据目标环境配置用户在安装过程中看到的内容。 例如,如果要将包分发到所有客户端进行手动安装,则应有完整的 UI。 但是,如果要使用组策略部署包,这不需要用户交互,则不应涉及任何 UI。
Syntax
msiexec.exe /i <path_to_package> [/quiet][/passive][/q{n|b|r|f}]
Parameters
Parameter | Description |
---|---|
<path_to_package> |
指定安装包文件的位置和名称。 |
/quiet | 指定静默模式,这意味着无需用户交互。 |
/passive | 指定无人参与模式,这意味着安装仅显示进度栏。 |
/qn | 指定安装过程中没有 UI。 |
/qn+ | 指定在安装过程中没有 UI,但末尾的最后一个对话框除外。 |
/qb | 指定在安装过程中有一个基本 UI。 |
/qb+ | 指定在安装过程中有一个基本 UI,包括最后一个对话框。 |
/qr | 指定在安装过程中减少的 UI 体验。 |
/qf | 指定安装过程中的完整 UI 体验。 |
Remarks
- 如果用户取消安装,则不会显示模式框。 You can use qb+! or qb!+ to hide the CANCEL button.
Examples
To install package C:\example.msi, using a normal installation process and no UI, type:
msiexec.exe /i "C:\example.msi" /qn
Restart options
如果安装包覆盖文件或尝试更改正在使用的文件,则安装完成后可能需要重新启动。
Syntax
msiexec.exe /i <path_to_package> [/norestart][/promptrestart][/forcerestart]
Parameters
Parameter | Description |
---|---|
<path_to_package> |
指定安装包文件的位置和名称。 |
/norestart | 在安装完成后停止设备重启。 |
/promptrestart | 如果需要重新启动,则提示用户。 |
/forcerestart | 安装完成后重启设备。 |
Examples
To install package C:\example.msi, using a normal installation process with no reboot at the end, type:
msiexec.exe /i "C:\example.msi" /norestart
Logging options
如果需要调试安装包,可以设置参数以创建包含特定信息的日志文件。
Syntax
msiexec.exe [/i][/x] <path_to_package> [/L{i|w|e|a|r|u|c|m|o|p|v|x+|!|*}] <path_to_log>
Parameters
Parameter | Description |
---|---|
/i | 指定正常安装。 |
/x | 卸载包。 |
<path_to_package> |
指定安装包文件的位置和名称。 |
/li | 打开日志记录,并在输出日志文件中包含状态消息。 |
/lw | 打开日志记录,并在输出日志文件中包含非致命警告。 |
/le | 启用日志记录,并在输出日志文件中包含所有错误消息。 |
/la | 打开日志记录,并包含有关作何时在输出日志文件中启动的信息。 |
/lr | 打开日志记录,并在输出日志文件中包含特定于作的记录。 |
/lu | 打开日志记录,并在输出日志文件中包含用户请求信息。 |
/lc | 打开日志记录,并在输出日志文件中包含初始 UI 参数。 |
/lm | 打开日志记录,并在输出日志文件中包含内存不足或致命退出信息。 |
/lo | 打开日志记录,并在输出日志文件中包含磁盘空间不足的消息。 |
/lp | 打开日志记录,并在输出日志文件中包含终端属性。 |
/lv | 打开日志记录,并在输出日志文件中包含详细输出。 |
/lx | 启用日志记录,并在输出日志文件中包含额外的调试信息。 |
/l+ | 打开日志记录并将信息追加到现有日志文件。 |
/l! | 打开日志记录并将每行刷新到日志文件。 |
/l* | Turns on logging and logs all information, except verbose information (/lv) or extra debugging information (/lx). |
<path_to_logfile> |
指定输出日志文件的位置和名称。 |
Examples
To install package C:\example.msi, using a normal installation process with all logging information provided, including verbose output, and storing the output log file at C:\package.log, type:
msiexec.exe /i "C:\example.msi" /L*V "C:\package.log"
Update options
可以使用安装包应用或删除更新。
Syntax
msiexec.exe [/p][/update][/uninstall[/package<product_code_of_package>]] <path_to_package>
Parameters
Parameter | Description |
---|---|
/p | 安装修补程序。 If you're installing silently, you must also set the REINSTALLMODE property to ecmus and REINSTALL to ALL. 否则,修补程序只会更新目标设备上缓存的 MSI。 |
/update | 安装修补程序选项。 如果要应用多个更新,则必须使用分号分隔它们(;))。 |
/package | 安装或配置产品。 |
Examples
msiexec.exe /p "C:\MyPatch.msp"
msiexec.exe /p "C:\MyPatch.msp" /qb REINSTALLMODE="ecmus" REINSTALL="ALL"
msiexec.exe /update "C:\MyPatch.msp"
msiexec.exe /uninstall {1BCBF52C-CD1B-454D-AEF7-852F73967318} /package {AAD3D77A-7476-469F-ADF4-04424124E91D}
其中第一个 GUID 是修补程序 GUID,第二个 GUID 是应用修补程序的 MSI 代码示例。
Repair options
可以使用此命令修复已安装的包。
Syntax
msiexec.exe [/f{p|o|e|d|c|a|u|m|s|v}] <product_code>
Parameters
Parameter | Description |
---|---|
/fp | 如果缺少文件,则修复包。 |
/fo | 如果缺少文件,或者安装了较旧版本,则修复包。 |
/fe | 如果缺少文件,或者安装了相等版本或较旧版本,则修复包。 |
/fd | 如果文件缺失或安装了其他版本,则修复包。 |
/fc | 如果缺少文件,或者校验和与计算值不匹配,则修复包。 |
/fa | 强制重新安装所有文件。 |
/fu | 修复所有必需的特定于用户的注册表项。 |
/fm | 修复所有必需的计算机特定注册表项。 |
/fs | 修复所有现有快捷方式。 |
/fv | 从源运行并重新缓存本地包。 |
Examples
To force all files to be reinstalled based on the MSI product code to be repaired, {AAD3D77A-7476-469F-ADF4-04424124E91D}, type:
msiexec.exe /fa {AAD3D77A-7476-469F-ADF4-04424124E91D}
设置公共属性
可以通过此命令设置公共属性。 For information about the available properties and how to set them, see Public Properties.