本帖最后由 apang 于 2015-2-28 10:21 编辑
- @set @n=0;/* & echo off
- set "k=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- set "Js=cscript -nologo -e:jscript"
- for /f "tokens=2*" %%a in ('reg query %k% /s^|%Js% "%~0"') do set "var=%%b"
- echo,%var%
- pause & exit/b */
-
- txt = WScript.StdIn.ReadAll() + "\r\nHKEY";
- re = /^HKEY[\s\S]+?(?=^HKEY)/img;
- while ((arr=re.exec(txt)) != null) {
- a = arr[0].match(/\bDisplayName\b +REG_SZ +(.*)\r\n/i);
- b = arr[0].match(/\bUninstallString\b.*\n/i);
- if (a && b) {
- if (a[1] == "Wolves (Application Proxy)") {
- WScript.Echo(b[0]); break
- }
- }
- }
复制代码 WinXP系统中,reg query 得到的结果与Win7有所不同
WinXP:注册表值、类型、数据之间以Tab分割(即DisplayName与REG_SZ之间以Tab分割)
Win7:注册表值、类型、数据之间以空格分割
第11行改成:- a = arr[0].match(/\bDisplayName\s+REG_SZ\s+(.*)\r\n/i);
复制代码 可两者兼顾 |