Package-Management
msiexec 刪除 dotnet Core 疑難解答
我正在嘗試在一組伺服器上將 ASP.NET Core 從 2.0.3 升級到 2.1.5。我正在使用一個看起來像這樣的 Powershell 腳本:
$software = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' $software += Get-ChildItem 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' $software | Where-Object { $_.GetValue('DisplayName') -like '*.net core*2.0.3*' } | ForEach-Object { write-verbose "Uninstalling $($_.GetValue('DisplayName'))" $guid = ([regex]'{[A-Z0-9-]+}').Match($_.Name).Value $process_params = @{ 'FilePath' = Join-Path -Path $env:SystemRoot -ChildPath 'system32' | Join-Path -ChildPath 'msiexec.exe'; 'ArgumentList' = @( "/x$guid", '/passive', '/norestart' ); 'Wait' = $True } Write-Verbose "Invoking Start-Process with parameters $(ConvertTo-Json $process_params)" Start-Process @process_params }
執行腳本後,沒有錯誤,但軟體沒有被刪除。嘗試刪除單個項目時出現同樣的問題
Start-Process -FilePath 'msiexec' -ArgumentList @('/x{402BF053-9B1B-4962-8784-DA77541C45A3}', '/passive', '/norestart') -Verbose -Wait
我什至嘗試過
win32_product
像這樣使用可怕的:(gwmi -Class win32_product -Filter "IdentifyingNumber='{402BF053-9B1B-4962-8784-DA77541C45A3}'").Uninstall()
這些選項都不起作用。添加
/log uninstall.log
到 msiexec 參數會產生以下日誌文件:=== Logging started: 10/11/2018 9:37:57 === Action start 9:37:57: INSTALL. Action start 9:37:57: FindRelatedProducts. Action ended 9:37:57: FindRelatedProducts. Return value 0. Action start 9:37:57: LaunchConditions. Action ended 9:37:57: LaunchConditions. Return value 1. Action start 9:37:57: ValidateProductID. Action ended 9:37:57: ValidateProductID. Return value 1. Action start 9:37:57: CostInitialize. Action ended 9:37:57: CostInitialize. Return value 1. Action start 9:37:57: FileCost. Action ended 9:37:57: FileCost. Return value 1. Action start 9:37:57: CostFinalize. Action ended 9:37:57: CostFinalize. Return value 1. Action start 9:37:57: MigrateFeatureStates. Action ended 9:37:57: MigrateFeatureStates. Return value 0. Action start 9:37:57: InstallValidate. Action ended 9:37:57: InstallValidate. Return value 1. Action start 9:37:57: WixDependencyCheck. If you continue with this uninstall, 1 or more products may stop working properly. Do you want to continue with this uninstall anyway? CustomAction WixDependencyCheck returned actual error code 259 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 9:37:57: WixDependencyCheck. Return value 5. Action ended 9:37:57: INSTALL. Return value 1. Property(S): UpgradeCode = {9E476537-57D3-4BCD-E354-3F9131F43B15} Property(S): DOTNETHOME = C:\Program Files (x86)\dotnet\ Property(S): TARGETDIR = C:\ Property(S): WixUIRMOption = UseRM Property(S): WIXUI_INSTALLDIR = DOTNETHOME Property(S): ALLUSERS = 1 Property(S): ARPNOMODIFY = 1 Property(S): ProgramFilesFolder = C:\Program Files (x86)\ Property(S): ProductCPU = x86 Property(S): RTM_ProductVersion = 16.12.25816 Property(S): MSIFASTINSTALL = 7 Property(S): Manufacturer = Microsoft Corporation Property(S): ProductCode = {402BF053-9B1B-4962-8784-DA77541C45A3} Property(S): ProductLanguage = 1033 Property(S): ProductName = Microsoft .NET Core Host - 2.0.3 (x86) Property(S): ProductVersion = 16.12.25816 Property(S): DefaultUIFont = WixUI_Font_Normal Property(S): WixUI_Mode = InstallDir Property(S): ErrorDialog = ErrorDlg Property(S): SecureCustomProperties = IGNOREDEPENDENCIES;WIX_DOWNGRADE_DETECTED;WIX_UPGRADE_DETECTED Property(S): MsiLogFileLocation = C:\Windows\system32\uninstall.log Property(S): PackageCode = {D490295B-DB46-41F3-BF1B-ED9A8E55B81B} Property(S): ProductState = 5 Property(S): ProductToBeRegistered = 1 Property(S): REBOOTPROMPT = S Property(S): REBOOT = ReallySuppress Property(S): REMOVE = ALL Property(S): CURRENTDIRECTORY = C:\Windows\system32 Property(S): CLIENTUILEVEL = 2 Property(S): CLIENTPROCESSID = 13344 Property(S): MsiSystemRebootPending = 1 Property(S): PRODUCTLANGUAGE = 1033 Property(S): VersionDatabase = 200 Property(S): VersionMsi = 5.00 Property(S): VersionNT = 603 Property(S): VersionNT64 = 603 Property(S): WindowsBuild = 9600 Property(S): ServicePackLevel = 0 Property(S): ServicePackLevelMinor = 0 Property(S): MsiNTProductType = 3 Property(S): WindowsFolder = C:\Windows\ Property(S): WindowsVolume = C:\ Property(S): System64Folder = C:\Windows\system32\ Property(S): SystemFolder = C:\Windows\SysWOW64\ Property(S): RemoteAdminTS = 1 Property(S): TempFolder = C:\Users\username_redacted\AppData\Local\Temp\ Property(S): CommonFilesFolder = C:\Program Files (x86)\Common Files\ Property(S): ProgramFiles64Folder = C:\Program Files\ Property(S): CommonFiles64Folder = C:\Program Files\Common Files\ Property(S): AppDataFolder = C:\Users\username_redacted\AppData\Roaming\ Property(S): FavoritesFolder = C:\Users\username_redacted\Favorites\ Property(S): NetHoodFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Network Shortcuts\ Property(S): PersonalFolder = C:\Users\username_redacted\Documents\ Property(S): PrintHoodFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Printer Shortcuts\ Property(S): RecentFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\Recent\ Property(S): SendToFolder = C:\Users\username_redacted\AppData\Roaming\Microsoft\Windows\SendTo\ Property(S): TemplateFolder = C:\ProgramData\Microsoft\Windows\Templates\ Property(S): CommonAppDataFolder = C:\ProgramData\ Property(S): LocalAppDataFolder = C:\Users\username_redacted\AppData\Local\ Property(S): MyPicturesFolder = C:\Users\username_redacted\Pictures\ Property(S): AdminToolsFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\ Property(S): StartupFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\ Property(S): ProgramMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ Property(S): StartMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\ Property(S): DesktopFolder = C:\Users\Public\Desktop\ Property(S): FontsFolder = C:\Windows\Fonts\ Property(S): GPTSupport = 1 Property(S): OLEAdvtSupport = 1 Property(S): ShellAdvtSupport = 1 Property(S): MsiAMD64 = 21 Property(S): Msix64 = 21 Property(S): Intel = 21 Property(S): PhysicalMemory = 10477 Property(S): VirtualMemory = 10819 Property(S): AdminUser = 1 Property(S): MsiTrueAdminUser = 1 Property(S): LogonUser = username_redacted Property(S): UserSID = S-1-5-21-3813976000-3187682355-4120183401-9416 Property(S): UserLanguageID = 1033 Property(S): ComputerName = VMTEST08 Property(S): SystemLanguageID = 1033 Property(S): ScreenX = 1024 Property(S): ScreenY = 768 Property(S): CaptionHeight = 23 Property(S): BorderTop = 1 Property(S): BorderSide = 1 Property(S): TextHeight = 16 Property(S): TextInternalLeading = 3 Property(S): ColorBits = 32 Property(S): TTCSupport = 1 Property(S): Time = 9:37:57 Property(S): Date = 10/11/2018 Property(S): MsiNetAssemblySupport = 4.7.3062.0 Property(S): MsiWin32AssemblySupport = 6.3.9600.17415 Property(S): RedirectedDllSupport = 2 Property(S): MsiRunningElevated = 1 Property(S): Privileged = 1 Property(S): Installed = 00:00:00 Property(S): DATABASE = C:\Windows\Installer\40b0b.msi Property(S): UILevel = 3 Property(S): OriginalDatabase = C:\Windows\Installer\40b0b.msi Property(S): MsiUIProgressOnly = 1 Property(S): MsiUIHideCancel = 1 Property(S): Preselected = 1 Property(S): ACTION = INSTALL Property(S): ROOTDRIVE = C:\ Property(S): CostingComplete = 1 Property(S): OutOfDiskSpace = 0 Property(S): OutOfNoRbDiskSpace = 0 Property(S): PrimaryVolumeSpaceAvailable = 0 Property(S): PrimaryVolumeSpaceRequired = 0 Property(S): PrimaryVolumeSpaceRemaining = 0 Property(S): INSTALLLEVEL = 1 MSI (s) (7C:C0) [09:37:57:357]: Product: Microsoft .NET Core Host - 2.0.3 (x86) -- Removal completed successfully. MSI (s) (7C:C0) [09:37:57:357]: Windows Installer removed the product. Product Name: Microsoft .NET Core Host - 2.0.3 (x86). Product Version: 16.12.25816. Product Language: 1033. Manufacturer: Microsoft Corporation. Removal success or error status: 0. === Logging stopped: 10/11/2018 9:37:57 ===
如您所見,即使是日誌文件也表明成功——但產品每次都仍然存在!對這個特定問題的幫助會很好,但我也很感激任何一般的 Windows Installer 故障排除,因為我沒有在 Web 上找到太多文件。感謝您的時間。
在日誌中,您可以看到 WixDependencyCheck 找到其他依賴於此的 MSI,並出錯。
將參數添加
IGNOREDEPENDENCIES=ALL
到 msiexec 應該可以修復它。
我遇到了同樣的問題(使用巧克力進行解除安裝)並最終得到了這個解決方案。(不要忘記更改 $version 變數以匹配您要刪除的版本)
$version = '2.2.6' $softwareName = '.Net Core' $searchString = "*$softwareName*$version*" $msiExecPath = Join-Path -Path $env:SystemRoot -ChildPath 'system32' | Join-Path -ChildPath 'msiexec.exe' function Find-DotNetCoreInstall { param ( $ver = $version, $softName = $softwareName ) $software = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' ) $searchString = "*$softwareName*$version*" $allDotNetItems = Get-ItemProperty $software | Where-Object {$_.displayName -like $searchString} | Select-Object DisplayName,DisplayVersion,UninstallString Write-Output $allDotNetItems } $allDotNetItems = Find-DotNetCoreInstall if($allDotNetItems.count -gt 0) { Write-Host "Uninstalling $($allDotNetItems.count) components for $softwareName $version" foreach($item in $allDotNetItems) { $uninstallString = $item.UninstallString $name = $item.DisplayName if ($uninstallString -like "MsiExec.exe *") { Write-Host "Uninstalling $name version: $($item.displayVersion)" $guid = ([regex]'{[A-Z0-9-]+}').Match($uninstallString).Value start-process -FilePath $msiExecPath -ArgumentList @("/x$guid", "/passive", "/quiet", "/norestart", "IGNOREDEPENDENCIES=ALL", "/log `"$env:temp\$($name)_Uninstall_$($version).log`"") -Wait } else { $filepath = ($uninstallString.Split('/')[0]).replace('"','') Write-Host "Uninstalling $name version: $($item.displayVersion)" Start-Process -FilePath $filepath -ArgumentList @("/uninstall", "/silent") -Wait } } } else { Write-Host "There are no installed components of $software $version" exit 0 } $finalCheck = Find-DotNetCoreInstall if ($finalCheck.count -eq 0){ Write-Host "All .NET components have been uninstalled" exit 0 } else { Write-Host "Error: NOT ALL COMPONENTS uninstalled! `n $finalCheck " exit 1 }