mbr*_*nyc 4 registry powershell uninstall
我在REG_SZ使用以下方法获取值时遇到了一些奇怪的麻烦:
(get-itemproperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player" -Name UninstallString).UninstallString
(get-itemproperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player" -Name UninstallString).UninstallString
get-itemproperty : Cannot find path 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\VLC media player' because it
does not exist.
At line:1 char:2
+ (get-itemproperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKEY_LOCAL_MACH...LC media player:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
Run Code Online (Sandbox Code Playgroud)
此方法适用于另一个REG_SZ没有问题的方法,但是当我在下面调用许多键时,Uninstall它将失败。
具体来说,它适用于:
(get-itemproperty -Path "Registry::HKEY_CURRENT_USER\Software\Microsoft\Command Processor" -Name autorun).AutoRun
这两个数据条目都在我的系统上存在,如regedit中所示。
但是,非常有趣的是,它们在以下结果中不存在:
Get-ChildItem "Registry::HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\uninstall\"
Run Code Online (Sandbox Code Playgroud)
还有更多的“缺失”键。这似乎是我不熟悉的一些奇怪的注册表名称空间虚拟化(类似于HKEY_CLASSES_ROOT)?
在这种情况下,由于键“丢失”,因此必须检查其他路径(请注意,test-path在尝试任何“错误”操作之前,我应先检查条件条件下的路径)。
PS > (dir HKLM:\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall | measure).count
134
PS > (dir hklm:\software\microsoft\windows\currentversion\uninstall | measure).count
134
Run Code Online (Sandbox Code Playgroud)
因此,我必须正在运行32位powershell.exe。
PS > [Environment]::Is64BitProcess
False
Run Code Online (Sandbox Code Playgroud)
另外,它HKEY_CLASSES_ROOT\Installer\Products是列出Windows Installer安装的程序的另一个位置。
对于32位和64位powershell.exe,此答案很有帮助。
该问题的解决方案是可靠的。我对先前链接的功能做了一些修改,以使其更易于访问。
PS我在Macbook Pro的Bootcamp上运行Windows 7。奇怪的是,无论我执行何种powershell.exe,它都是32位的。我根本看不到注册表项,无论该位置是否在wow6432node。