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

如何为注册表中的UninstallString值添加首尾引号

问题分析与解决方法

原命令的核心错误

  1. 注册表路径冗余:HKLM:已经是HKEY_LOCAL_MACHINE的PowerShell驱动器映射,路径里重复写HKEY_LOCAL_MACHINE会导致路径无效。
  2. 字符串引号转义错误:双引号字符串中嵌套双引号时未正确转义,PowerShell无法识别完整的Value内容。
  3. 命令选型错误:如果UninstallString属性已存在,New-ItemProperty会触发冲突报错,应使用Set-ItemProperty修改现有属性。

正确命令写法

写法一:用反引号转义双引号

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)" -Name "UninstallString" -Value `"C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)\install.exe`" -PropertyType String

写法二:用单引号包裹值内容(更简洁)

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)" -Name "UninstallString" -Value '"C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)\install.exe"' -PropertyType String

补充:创建新属性(确认属性不存在时使用)

如果确定UninstallString不存在,可使用New-ItemProperty并添加-Force参数避免冲突:

New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)" -Name "UninstallString" -Value '"C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)\install.exe"' -PropertyType String -Force

验证修改结果

执行命令后,可通过以下命令查看修改后的注册表值:

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)" -Name "UninstallString"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 18:40:24