gpt4 book ai didi

windows - 如何在批处理或 VBScript 中使用通配符搜索注册表中的键?

转载 作者:可可西里 更新时间:2023-11-01 10:28:15 30 4
gpt4 key购买 nike

我需要制作一个批处理或一个 VBScript,它可以卸载每个版本的 Mozilla Firefox。在注册表中有一个键:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Firefox (Version). 

Version 具有已安装的 Firefox 版本的值。在此键下有一个条目 UninstallString。我需要以某种方式阅读这个值。问题是 Version 是一个变量。因此,如果安装了 Mozilla Firefox 1.0.1,则 key 将如下所示:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Firefox (1.0.1).

如果安装了 2.0.2,则 key 将如下所示:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mozilla Firefox (2.0.2).

但我不知道安装的是哪个版本。那么我如何在不知道安装了哪个版本的情况下读取这个键(和卸载值)呢?有人可以帮助我吗?

谢谢。

最佳答案

怎么样:

const HKEY_LOCAL_MACHINE = &H80000002
const REG_PATH = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
const FOX_MASK = "Mozilla Firefox*"

dim re: set re = New RegExp
re.IgnoreCase = True
re.Global = True
re.Pattern = FOX_MASK

dim oReg: set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKEY_LOCAL_MACHINE, REG_PATH, arrSubKeys

dim strValue
for each subkey In arrSubKeys
if re.test(subkey) then
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, REG_PATH & subkey, "UninstallString", strValue
WScript.StdOut.WriteLine "Version: " & subkey
WScript.StdOut.WriteLine "Uninstaller: " & strValue
end if
next

对我来说输出:


<b>Version:</b> Mozilla Firefox 7.0 (x86 en-GB)



<b>Uninstaller:</b> C:\Program Files\Mozilla Firefox\uninstall\helper.exe

(注意这与您的模式不同)

关于windows - 如何在批处理或 VBScript 中使用通配符搜索注册表中的键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7498252/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com