<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBS: быстрое чтение информации об установленных программах]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5888&amp;type=atom" />
	<updated>2011-06-08T05:23:58Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5888</id>
		<entry>
			<title type="html"><![CDATA[Re: VBS: быстрое чтение информации об установленных программах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49039#p49039" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>JSman пишет:</cite><blockquote><p>И кстати, win32_product на некоторых системах не дает всю информацию.</p><p>Я поступил чуток по-другому. Не так красиво.<br /></p><div class="codebox"><pre><code>function ExportAddRemoveProgramsDataToFile(FilePath)
{
    FilePath = FilePath || &quot;%TMP%\\Progs.txt&quot;;
    var Command = &#039;REG EXPORT &quot;HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall&quot; &quot;&#039;+FilePath+&#039;&quot; \/y&#039;;
    WshShell.Run(Command,0,1);
    
    //var Result = GetAbsolutePath(FilePath); return Result;
}</code></pre></div></blockquote></div><p>Здорово! Я вообще за простоту. Если не&nbsp; надо читать REG_EXPAND_SZ то самое оно.</p>]]></content>
			<author>
				<name><![CDATA[Alexey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2696</uri>
			</author>
			<updated>2011-06-08T05:23:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49039#p49039</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBS: быстрое чтение информации об установленных программах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49035#p49035" />
			<content type="html"><![CDATA[<p>И кстати, win32_product на некоторых системах не дает всю информацию.</p><p>Я поступил чуток по-другому. Не так красиво.<br /></p><div class="codebox"><pre><code>function ExportAddRemoveProgramsDataToFile(FilePath)
{
    FilePath = FilePath || &quot;%TMP%\\Progs.txt&quot;;
    var Command = &#039;REG EXPORT &quot;HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall&quot; &quot;&#039;+FilePath+&#039;&quot; \/y&#039;;
    WshShell.Run(Command,0,1);
    
    //var Result = GetAbsolutePath(FilePath); return Result;
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2011-06-07T21:03:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49035#p49035</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBS: быстрое чтение информации об установленных программах]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=49030#p49030" />
			<content type="html"><![CDATA[<p>Задача: получить данные из реестра об установленной программе с учетом архитектуры операционной системы (x64/x86)<br />Варианты решения: <br />а) можно получить данные через wmi через win32_product, но скорость выполнения запроса оставляет желать лучшего...<br />б) получить напрямую из HKLM\software\Microsoft\CurrentVersion\Uninstall, но если делать это напрямую хоть через WMI, хоть через WshShell.RegRead возникает зависимость от разрядности запускающего процесса. То есть если родительский процесс 64-битный то обращение идет к 64-битной ветке реестра, и напротив, от 32-битного родительского потока обращение пойдет к 32-битной ветке.<br />Решение:<br /></p><div class="codebox"><pre><code>
Function GetSoftware(display_name,get_string_param)
	On Error Resume Next
	ret=&quot;&quot;
	uninstall_string=&quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\&quot;
	HKLM=&amp;H80000002
	Set objWMI = GetObject(&quot;winmgmts:\\.\root\CIMV2&quot;)
	Set objCtx = CreateObject(&quot;WbemScripting.SWbemNamedValueSet&quot;)
	If GetOsArchitecture=&quot;64&quot; Then
		objCtx.Add &quot;__ProviderArchitecture&quot;, 64
	Else
		objCtx.Add &quot;__ProviderArchitecture&quot;, 32
	End If
	Set objLocator = CreateObject(&quot;Wbemscripting.SWbemLocator&quot;)
	Set objServices = objLocator.ConnectServer(&quot;&quot;,&quot;root\default&quot;,&quot;&quot;,&quot;&quot;,,,,objCtx)
	Set objStdRegProv = objServices.Get(&quot;StdRegProv&quot;)
	Set InParams = objStdRegProv.Methods_(&quot;EnumKey&quot;).InParameters
	Inparams.Hdefkey = HKLM
	Inparams.Ssubkeyname = uninstall_string
	Set Outparams = objStdRegProv.ExecMethod_(&quot;EnumKey&quot;, Inparams,,objCtx)
	For Each strSubKey In Outparams.sNames
		Set InParam = objStdRegProv.Methods_(&quot;GetStringValue&quot;).InParameters
		Inparam.sSubKeyName=uninstall_string &amp;&quot;\&quot;&amp; strSubKey
		Inparam.Hdefkey = HKLM
		Inparam.sValueName=&quot;DisplayName&quot;
		Set OutParam = objStdRegProv.ExecMethod_(&quot;GetStringValue&quot;, Inparam,,objCtx)
		If (StrComp(OutParam.sValue,display_name,1)=0) Then
			Set InValue = objStdRegProv.Methods_(&quot;GetStringValue&quot;).InParameters
			InValue.sSubKeyName=uninstall_string &amp;&quot;\&quot;&amp; strSubKey
			InValue.Hdefkey = HKLM
			InValue.sValueName=get_string_param
			Set oValue = objStdRegProv.ExecMethod_(&quot;GetStringValue&quot;, InValue,,objCtx)
			ret=oValue.sValue
			Set InValue=Nothing
		End If
		Set InParam=Nothing
	Next
	If ret=&quot;&quot; Then
		GetSoftware=&quot;отсутствует&quot;
	Else
		GetSoftware=ret
	End if
	Set InParams=Nothing
	Set objStdRegProv = Nothing
	Set objServices = Nothing
	Set objLocator = Nothing
	Set objCtx = Nothing
	Set objWMI = Nothing
	On Error Goto 0
End Function

Function GetOsArchitecture
	On Error Resume next
	GetOsArchitecture=&quot;32&quot;
	Const wbemFlagReturnImmediately = &amp;h10
	Const wbemFlagForwardOnly = &amp;h20
	Set objWMIService = GetObject(&quot;winmgmts:\\.\root\CIMV2&quot;)
   	Set colItems = objWMIService.ExecQuery(&quot;SELECT * FROM Win32_OperatingSystem&quot;)
	For Each objItem In colItems
		GetOsArchitecture=Left(objItem.OSArchitecture,2)
	Next
	Set objWMIService = Nothing
	Set colItems = Nothing
	On Error GoTo 0
End Function

MsgBox GetSoftware(&quot;Microsoft .NET Framework 4 Extended&quot;,&quot;DisplayVersion&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alexey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2696</uri>
			</author>
			<updated>2011-06-07T19:17:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=49030#p49030</id>
		</entry>
</feed>
