Windows卸载文件路径查找

1、在控制面板中发现e管家软件,如何查找文件位置、按照路径等信息

image

2、在开始菜单运行Powershell——快捷键Win+X,选 “终端(管理员)”

image

执行以下命令

对比卸载程序中的名字,修改关键字段:“$targetDisplayName='e管家'

$targetDisplayName='e管家';$uninstallReg=Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*,HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* -ErrorAction SilentlyContinue | Where-Object {$_.DisplayName -eq $targetDisplayName};if(-not $uninstallReg){Write-Warning '未找到该卸载项,请核对软件名称';return};$out=@();$out+="`n==========【1 卸载注册表信息】==========";$out+=($uninstallReg | Select-Object PSPath,DisplayName,DisplayVersion,Publisher,InstallDate,InstallLocation,UninstallString,DisplayIcon | Format-List | Out-String);$installLocation=$uninstallReg.InstallLocation;$uninstallExePath=if($uninstallReg.UninstallString){($uninstallReg.UninstallString -split '"')[1]}else{$null};$mainExePath=$uninstallReg.DisplayIcon;
# 修复:向上取一级为软件真实顶层根目录
if(-not [string]::IsNullOrWhiteSpace($installLocation)){$softwareRoot=Split-Path $installLocation -Parent}elseif($uninstallExePath -and (Test-Path $uninstallExePath)){$softwareRoot=Split-Path (Split-Path $uninstallExePath -Parent) -Parent}else{$softwareRoot=$null};
$out+="";$out+=("注册表InstallLocation(注册表记录): "+$(if($installLocation){$installLocation}else{'(空)'}));$out+=("软件真实顶层根目录(推断):        "+$(if($softwareRoot){$softwareRoot}else{'无法推断'}));$out+=("卸载程序路径:          "+$(if($uninstallExePath){$uninstallExePath}else{'无'}));$out+=("图标/主程序路径:       "+$(if($mainExePath){$mainExePath}else{'无'}));
$out+="`n==========【2 程序文件版本信息】==========";$fileList=@($mainExePath,$uninstallExePath)|Where-Object {$_ -and (Test-Path $_ -PathType Leaf)};
if($fileList.Count -eq 0){$out+="警告:没有获取到可访问的程序文件路径"}else{foreach($fp in $fileList){$fi=Get-Item $fp;$out+="`n文件路径: $fp";$out+=($fi.VersionInfo | Select-Object FileVersion,ProductVersion,CompanyName,OriginalFilename,FileDescription | Format-List | Out-String);$out+=("文件创建时间: "+$fi.CreationTime);$out+=("文件修改时间: "+$fi.LastWriteTime)}}
$out+="`n==========【3 磁盘目录占用(完整顶层目录)】==========";
if($softwareRoot -and (Test-Path $softwareRoot)){$files=Get-ChildItem -Path $softwareRoot -Recurse -File -ErrorAction SilentlyContinue;$totalBytes=($files|Measure-Object Length -Sum).Sum;$totalMB=[math]::Round($totalBytes/1MB,2);$out+=("软件顶层根目录:$softwareRoot");$out+=("总文件数: "+$files.Count);$out+=("总占用大小(MB): "+$totalMB)}else{$out+="警告:软件根目录不存在或无法推断"}
$out+="`n==========【4 相关系统服务(仅匹配软件目录关键字)】==========";
$matchKeyword=if($softwareRoot){(Split-Path $softwareRoot -Leaf).Trim()}else{$null};
$out+=((Get-CimInstance Win32_Service -ErrorAction SilentlyContinue | Where-Object {$matchKeyword -and $_.PathName -match [regex]::Escape($matchKeyword)} | Select-Object Name,DisplayName,State,StartMode,PathName | Format-List | Out-String));
$out+="`n==========【5 正在运行的相关进程】==========";
$out+=((Get-Process -ErrorAction SilentlyContinue | Where-Object {$_.Path -and $matchKeyword -and $_.Path -match [regex]::Escape($matchKeyword)} | Select-Object Id,Name,Path,Company | Format-List | Out-String));
$out+="`n==========【采集完成】==========";$out | Out-File "D:\下载\AppReport.txt" -Encoding UTF8;$out

执行回车后,可以看到结果:

 image

 

如果你不确定程序名称,可以先模糊查询

# 模糊搜索关键词,查询完整名称

$searchKeyword = "管家"

Get-ItemProperty `
    HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*,
    HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* `
    -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -match $searchKeyword } |
Select-Object DisplayName,DisplayVersion,Publisher,InstallLocation,PSPath | Format-List

案例:模糊搜索“HP”后出现,HP Documentation、HP Enabling Services、HP PSDr NTService Component、HP Connection Optimizer、HP Software Framework等

image 

 

posted @ 2026-09-02 11:55  Magiclala  阅读(21)  评论(0)    收藏  举报