【发布时间】:2018-11-20 12:22:52
【问题描述】:
我正在从 Chrome 卸载程序中提取卸载字符串,以便使用以下方式进行无人值守的静默卸载:
$UninstallStrings = Get-ItemProperty -Path "HKLM:\SOFTWARE\WoW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" |
Where-Object{$_.DisplayName -like $ProgramName} |
Select-Object -ExpandProperty UninstallString -ea SilentlyContinue
这给了我这个结果:
"C:\Program Files (x86)\Google\Chrome\Application\67.0.3396.79\Installer\setup.exe" --uninstall --system-level现在要继续卸载,我想我需要从结果中删除参数,然后执行Start-Process。任何人都可以提示删除参数并将它们添加为-ArgumentsList 之后的正确方法吗?
【问题讨论】:
-
$UninstallStrings | Invoke-Expression -
收到错误“表达式或语句中出现意外的令牌‘卸载’。”使用 $UninstallStrings |调用表达式。我想去掉 --uninstall...... 位,并在脚本开头定义的 .exe 中添加一组不同的变量。
-
试试
$UninstallStrings -replace '^', '& ' | Invoke-Expression。