首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >选择要删除的Netweaver版本

选择要删除的Netweaver版本
EN

Stack Overflow用户
提问于 2016-06-30 21:11:52
回答 1查看 115关注 0票数 1

我已经走到这一步了,但是它删除了SAP的所有版本,我只想删除某些版本。我已尝试更改我要搜索的内容,但仍会删除SAP的所有版本

代码语言:javascript
复制
$y = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
            Get-ItemProperty |
                Where-Object {$_.DisplayName -match 'SAP Netweaver Business Client 3.5' } |
                    Select-Object -Property DisplayName, UninstallString, PSPath

        foreach ($x in $y) 
        {
            if ($x.UninstallString) 
            {
                $uninst = "C:\Program Files (x86)\SAP\SapSetup\Setup\nwsapsetup.exe" 
                Start-Process $uninst -ArgumentList "/uninstall /nodlg /force"
            } 
         }
EN

回答 1

Stack Overflow用户

发布于 2016-07-01 01:05:14

最终脚本

这将删除Netweaver的所有版本。这不是我的功劳,因为我的同事创造了这个。

代码语言:javascript
复制
$y = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
    Get-ItemProperty |
        Where-Object {$_.DisplayName -match "SAP Netweaver Business Client" -and $_.Publisher -match "SAP AG" } |
            Select-Object -Property DisplayName, UninstallString, PSPath

foreach ($x in $y) {
if ($x.UninstallString -like "MsiExec.exe*") {
   $x.UninstallString = $x.UninstallString -replace "/i","/x" #replace /i with /x to ensure uninstall command is executed
   $x.UninstallString = $x.UninstallString -replace "MsiExec.exe ","" #remove MsiExec.exe so that only arguements are left
   $x.UninstallString = "$($x.UninstallString) /qn" #append the /qn for silent uninstall
    Start-Process -filepath "MsiExec.exe" -ArgumentList "$($x.UninstallString)" -Wait -WindowStyle Hidden
} else {
   #check to see if the UninstallString contains quotes
    $x.UninstallString = "$($x.UninstallString) /nodlg" 
    Start-Process cmd.exe -ArgumentList "/c `"$($x.UninstallString)`"" -WindowStyle Hidden -Wait
    write-host "$($x.displayname) uninstalled"
}
} 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38124186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档