Mag*_*Tun 4 registry powershell
我想删除包含1000+HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components的所有密钥(1000+)
例如,我想删除与该类似的所有键:
键名: Python35
名称: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components\0027CAECCC428F356B8D845FF8331246我试过这个.
Get-ChildItem -path HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components\ -Recurse | where { $_.Name -match 'Python35'} | Remove-Item -Force
Run Code Online (Sandbox Code Playgroud)
Powershell运行没有错误但是当我检查注册表时,密钥仍然存在.
Powershell以管理员身份运行,管理员拥有密钥的所有权,0F617A7B1C879BC47865E0155CDD6722并且对该密钥及其子密钥具有完全控制权
小智 5
请尝试以下脚本:
$RE = 'Python35'
$Key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-2\Components'
Get-ChildItem $Key -Rec -EA SilentlyContinue | ForEach-Object {
$CurrentKey = (Get-ItemProperty -Path $_.PsPath)
If ($CurrentKey -match $RE){
$CurrentKey|Remove-Item -Force -Whatif
}
}
Run Code Online (Sandbox Code Playgroud)
如果输出看起来没问题,请-WhatIf从中删除参数Remove-Item
| 归档时间: |
|
| 查看次数: |
6572 次 |
| 最近记录: |