You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过PowerShell将REG文件加入IntuneWinAppUtil打包的MSI?

将注册表配置整合到Intune部署的MSI应用中的步骤

1. 编写PowerShell注册表配置脚本

直接把你需要的注册表项转换成PowerShell命令,避免导入REG文件可能出现的权限或位数兼容性问题。创建一个名为Set-LynxRegSettings.ps1的脚本,内容如下:

# 定义目标注册表路径
$regPath = "HKLM:\SOFTWARE\Sahara\Lynx 4\OrganizationDefaults"

# 检查路径是否存在,不存在则创建
if (-not (Test-Path -Path $regPath)) {
    New-Item -Path $regPath -Force | Out-Null
}

# 逐个设置注册表键值
Set-ItemProperty -Path $regPath -Name "Lynx4Code" -Value "CPS-Prod-Key-123456789" -Type String
Set-ItemProperty -Path $regPath -Name "Name" -Value "The Management Team" -Type String
Set-ItemProperty -Path $regPath -Name "Email" -Value "office@orgdomain.com" -Type String
Set-ItemProperty -Path $regPath -Name "Organisation" -Value "Org Name" -Type String
Set-ItemProperty -Path $regPath -Name "Address" -Value "Org Address" -Type String
Set-ItemProperty -Path $regPath -Name "PostCode" -Value "P0STC0D3" -Type String
Set-ItemProperty -Path $regPath -Name "Country" -Value "GB" -Type String
Set-ItemProperty -Path $regPath -Name "LynxTerms" -Value "true" -Type String
Set-ItemProperty -Path $regPath -Name "SerialNumber" -Value "" -Type String
Set-ItemProperty -Path $regPath -Name "Trial" -Value "false" -Type String

注意:32/64位兼容性

如果你的MSI是32位,且部署到64位设备,注册表会被默认重定向到HKLM:\SOFTWARE\Wow6432Node。若要强制写入64位路径,修改脚本中的路径检查和创建逻辑:

if (-not (Test-Path -Path $regPath -RegistryView 64)) {
    New-Item -Path $regPath -Force -RegistryView 64 | Out-Null
}
# 每个Set-ItemProperty命令后也加上 -RegistryView 64
Set-ItemProperty -Path $regPath -Name "Lynx4Code" -Value "CPS-Prod-Key-123456789" -Type String -RegistryView 64

2. 用IntuneWinAppUtil打包MSI和脚本

  • 新建一个文件夹(比如LynxAppPackage),将你的MSI安装文件和Set-LynxRegSettings.ps1脚本放入其中。
  • 打开命令提示符,运行IntuneWinAppUtil工具,命令格式:
IntuneWinAppUtil.exe -c "C:\Path\To\LynxAppPackage" -s "YourAppName.msi" -o "C:\Path\To\OutputFolder"

参数说明:

  • -c:包含MSI和脚本的源文件夹路径
  • -s:主安装文件(你的MSI文件名)
  • -o:生成的.intunewin文件输出路径

3. 在Intune中配置应用部署

  1. 登录Intune管理中心,创建Windows应用(Win32),上传打包好的.intunewin文件。
  2. 在安装程序标签页,设置安装命令:
msiexec /i "YourAppName.msi" /qn
  1. 切换到后续安装标签页,添加注册表脚本:
    • 选择添加脚本,脚本类型选PowerShell
    • 脚本位置选包内,然后选中Set-LynxRegSettings.ps1
    • 运行上下文选择系统(必须用系统权限才能写入HKLM注册表)
    • 若部署到64位设备,勾选在64位PowerShell宿主中运行此脚本

完成以上配置后,即可将应用部署到目标设备,安装MSI后会自动执行脚本配置注册表。

内容的提问来源于stack exchange,提问作者talksr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 11:13:15