2014-05-23 2 views
1

제어판의 프로그램 제거에 나와있는대로 설치된 소프트웨어를 가져와야합니다. 그래서 VB 스크립트에서 쿼리에 Win32_RegistryAction 클래스를 사용했습니다. 하지만 여전히 특정 키를 쿼리 할 수 ​​없으며 중단됩니다. 여기 내가 사용한 코드 조각이있다. wmi 쿼리를 사용하여 설치된 소프트웨어 세부 정보를 얻는 방법을 알려주십시오. 당신은 잘못된 WMI 클래스를 사용하는 사전Windows에서 wmi 쿼리를 사용하여 레지스트리를 쿼리하는 중

strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2") 

Set colSettings = objWMIService.ExecQuery _ 
("Select * from Win32_RegistryAction where key ='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\' and Root=2 ") 

For Each objComputer in colSettings 
Wscript.Echo "Display Name: " & objComputer.DisplayName  
Next 

답변

0

나는 내 자신의 질문에 대답하고 있습니다. RRUZ에게 올바른 방법으로 리드 해 주셔서 감사합니다. 여기에이 문제에 대한 해결책이 있습니다. 이제는 Windows에서 제거 프로그램을 보여주는 모든 설치된 소프트웨어를 가져올 수 있습니다. 샘플 코드는 소프트웨어 \ Wow6432Node \ 마이크로 소프트 \ 윈도우 \ CurrentVersion \ 제거 위 Windows 7 또는에만 적용됩니다 여기에 경로 여기

Dim count 
Const HKEY_LOCAL_MACHINE = &H80000002 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") 
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall" 
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames 
count = 0 
For i=0 To UBound(arrValueNames) 
StrText = arrValueNames(i) 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayName",strName 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayVersion",strVersion 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallLocation",strLocation 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallDate",strDate 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "SystemComponent",strSystemComponent 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "WindowsInstaller",strWindowsInstaller 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "UninstallString",strUninstallString 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ReleaseType",strReleaseType 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ParentKeyName",strParentKeyName 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "Publisher",strPublisher 
if isNull(strSystemComponent) then 
if isNull(strWindowsInstaller) then 
if not isNull(strUninstallString) then 
if isNull(strReleaseType) then 
if isNull(strParentKeyName) then 
if not isNull(strName) then 
printKeyValue "Win32_Product.PackageName[" & count & "]", StrName 
printKeyValue "Win32_Product.Version[" & count & "]", StrVersion 
printKeyValue "Win32_Product.InstallLocation[" & count & "]", strLocation 
printKeyValue "Win32_Product.InstallDate[" & count & "]", strDate 
printKeyValue "Win32_Product.Publisher[" & count & "]", strPublisher 
printKeyValue "Win32_Product.WindowsInstaller[" & count & "]", strWindowsInstaller 
printKeyValue "Win32_Product.UninstallString[" & count & "]", strUninstallString 
printKeyValue "Win32_Product.ReleaseType[" & count & "]", strReleaseType 
printKeyValue "Win32_Product.ParentKeyName[" & count & "]", strParentKeyName 
count = count + 1 
end if 
end if 
end if 
end if 
end if 
end if 
Next 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") 
strKeyPath = "Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames 
For i=0 To UBound(arrValueNames) 
StrText = arrValueNames(i) 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayName",strName 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "DisplayVersion",strVersion 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallLocation",strLocation 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "InstallDate",strDate 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "SystemComponent",strSystemComponent 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "WindowsInstaller",strWindowsInstaller 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "UninstallString",strUninstallString 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ReleaseType",strReleaseType 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "ParentKeyName",strParentKeyName 
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "\" & arrValueNames(i), "Publisher",strPublisher 
if isNull(strSystemComponent) then 
if isNull(strWindowsInstaller) then 
if not isNull(strUninstallString) then 
if isNull(strReleaseType) then 
if isNull(strParentKeyName) then 
if not isNull(strName) then 
printKeyValue "Win32_Product.PackageName[" & count & "]", StrName 
printKeyValue "Win32_Product.Version[" & count & "]", StrVersion 
printKeyValue "Win32_Product.InstallLocation[" & count & "]", strLocation 
printKeyValue "Win32_Product.InstallDate[" & count & "]", strDate 
printKeyValue "Win32_Product.Publisher[" & count & "]", strPublisher 
printKeyValue "Win32_Product.WindowsInstaller[" & count & "]", strWindowsInstaller 
printKeyValue "Win32_Product.UninstallString[" & count & "]", strUninstallString 
printKeyValue "Win32_Product.ReleaseType[" & count & "]", strReleaseType 
printKeyValue "Win32_Product.ParentKeyName[" & count & "]", strParentKeyName 
count = count + 1 
end if 
end if 
end if 
end if 
end if 
end if 
Next 
Function printKeyValue(key, value) 
Wscript.Echo key & "=>" & value 
End Function 

을주고있다.

관련 문제