<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; VBS запускается от 32-битного родительского потока, на x64. Реестр x3]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=7336</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=7336&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «VBS запускается от 32-битного родительского потока, на x64. Реестр x3».]]></description>
		<lastBuildDate>Thu, 26 Jul 2012 09:42:08 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: VBS запускается от 32-битного родительского потока, на x64. Реестр x3]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=62046#p62046</link>
			<description><![CDATA[<p>если вдруг кому понадобиться помогла&nbsp; еще статья http://msdn.microsoft.com/en-us/library/windows/desktop/aa393067%28v=vs.85%29.aspx <br />реализовал дополнительно двумя функциями для GetStringValue и EnumKey<br />&nbsp; </p><div class="codebox"><pre><code>Rem AutoCAD Fonts
rem Option Explicit
on error resume Next
Const HKEY_CURRENT_USER = &amp;H80000001
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const HKEY_USERS = &amp;H80000003 &#039;HKEY_USERS

Const ForWriting = 2
Const ForAppending=8

Const Create = True
Const Modal = True
Const TimeOut1 = &quot;0&quot;
Const TimeOut2 = &quot;5&quot;
Const OverwriteExisting = True

Const  EVENT_SUCCESS=0
Const  EVENT_ERROR=1
Const  EVENT_WARNING=2
Const  EVENT_INFORMATION=4


Rem ----------------------------------------------------------------------------------------------
&#039; путь к логам
strLogPath = &quot;\\server\LOGS\APP\Autodesk\Fonts\&quot;
strValueName = &quot;ProductName&quot;
strAcadLocation = &quot;Location&quot;
dim strLogMessage &#039;содержит текст протокола установки
Dim objShell
dim objWMIService
dim oRegistry
dim WshNetwork
dim objFSO
dim filename
strComputer=&quot;.&quot;
strLogMessage = &quot;&quot;
Set objShell = CreateObject(&quot;WScript.Shell&quot;)
Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;)
Set oRegistry=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; _
    strComputer &amp; &quot;\root\default:StdRegProv&quot;)
Set WshNetwork = CreateObject(&quot;WScript.Network&quot;)
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Rem Проверяем наличие входного параметра
strAction = &quot;&quot;
Set objArgs = WScript.Arguments
If WScript.Arguments.Count &gt; 0 Then
    strAction = UCase(Trim(WScript.Arguments(0)))
End If
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rem Открываем лог
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strFileLogName = strLogPath &amp; WshNetwork.ComputerName &amp; &quot;.log&quot;
Rem Выполняем поиск в реестре записи о приложении
strKeyPath = &quot;SOFTWARE\Autodesk\AutoCAD&quot;

Err.clear
    
    Rem ----- Проверка Есть ли раздел---------------------------
        Err.clear
    value1 = objShell.RegRead(&quot;HKLM\SOFTWARE\Autodesk\&quot;)
          if err.number &lt;&gt; 0 then
        rem     MSGBOX &quot;Нет раздела HKLM\SOFTWARE\Autodesk\&quot;    
    else
        rem     MSGBOX &quot;Есть раздел&quot;    
        Set objFileLog = objFSO.OpenTextFile(strFileLogName, ForAppending, True )
        rem ---    Если есть то создаем лог------ 
        if err.number&lt;&gt;0 then
            MSGBOX &quot;Не удалось создать файл с протоколом &quot; &amp; strFileLogName &amp; &quot;: &quot; &amp; err.description
            wscript.Quit(-1)
        End If        
            writelog vbcrlf 
        writelog &quot;********************&quot;
        writelog Now
        writelog &quot;********************&quot;        
            writelog &quot;Копирование шрифтов в AutoCAD и DWG trueview Ищем Папки&quot;
        strWorkingDir = objShell.CurrentDirectory
        strFontPath=strWorkingDir&amp;&quot;\fonts&quot;
        rem MSGBOX strWorkingDir
        writelog &quot;Папка с шрифтами    &quot; &amp; strFontPath
        Check64=objShell.regread (&quot;HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier&quot;)
        writelog vbTab&amp;&quot;Процесор  &quot;&amp; Check64
        If InStr(Check64,&quot;x86&quot;)&gt;0 Then
             OSver=32        
        Else
             OSver=64        
        End If
        strKeyPathTru=&quot;SOFTWARE\Autodesk\AutoCAD&quot;
         FindANDCopyFont (strKeyPathTru)
        strKeyPathTru=&quot;SOFTWARE\Autodesk\DWG TrueView&quot;
         FindANDCopyFont (strKeyPathTru)    
     end if
Set objWMIService = Nothing
WScript.Quit
rem ================================== Основа =========================================================
sub FindANDCopyFont (strKeyPath)
 rem oRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    arrSubKeys=ReadEnumKey(HKEY_LOCAL_MACHINE, strKeyPath , 64)
    rem +++++++++++++ Ищем Все ключи реестра в разделе ++++++++++++++++ 
      For Each subkey In arrSubKeys    
        key = strKeyPath &amp; &quot;\&quot; &amp; subkey
         arrSubKeys1=ReadEnumKey(HKEY_LOCAL_MACHINE, key , 64)
        rem oRegistry.EnumKey HKEY_LOCAL_MACHINE, key, arrSubKeys1
        For Each subkey1 In arrSubKeys1
            key1=key &amp; &quot;\&quot; &amp; subkey1
            writelog vbTab &amp; key1
            strValueNameValue=&quot;&quot;
            strAcadLocationeValue=&quot;&quot;
            
            
            strValueNameValue= ReadRegStr (HKEY_LOCAL_MACHINE, key1 ,strValueName ,OSver)
            rem WScript.Echo &quot;strValueNameValue=&quot;&amp;strValueNameValue&amp;&quot;   strValueName=&quot;&amp;strValueName&amp;&quot;  key1=&quot;&amp;key1
            rem oRegistry.GetStringValue HKEY_LOCAL_MACHINE,key1,strValueName,strValueNameValue    
            strAcadLocationeValue =ReadRegStr (HKEY_LOCAL_MACHINE, key1 ,strAcadLocation ,OSver)
            rem oRegistry.GetStringValue HKEY_LOCAL_MACHINE,key1,strAcadLocation,strAcadLocationeValue
            rem определяем путь шрифтов
            if strValueNameValue &lt;&gt;&quot;&quot; then        
                strAcadLocationeValue=strAcadLocationeValue&amp;&quot;\Fonts&quot;
                writelog vbTab &amp; strValueNameValue &amp; vbtab &amp; strAcadLocationeValue
                Set objFolder = objFSO.GetFolder(strFontPath)
                Set colFiles = objFolder.Files
                rem ------------ Проверка есть ли в папке шрифт или нет и его копирование -------------------------------     
                For Each objFile in colFiles
                    filename=strAcadLocationeValue &amp; &quot;\&quot; &amp; objFile.Name         
                    if  (objFSO.FileExists(filename))  Then
                          writelog vbTab &amp; objFile.Name &amp;&quot;  Файл  существует  в папке &quot; &amp; filename             
                    else              
                          writelog vbTab &amp; &quot;Файл не существует копируем в &quot; &amp; filename
                        objFSO.CopyFile (strFontPath &amp; &quot;\&quot; &amp; objFile.Name) , strAcadLocationeValue &amp;&quot;\&quot; , OverwriteExisting
                    end if              
                Next
            end if    
          next          
      Next    
end sub

rem ===================================================================================================
rem -------------------------------------Чтение значения реестра учитывая разрядность------------------
Function ReadRegStr (RootKey, Key5, Value, RegType) 
    Dim oCtx, oLocator, oReg, oInParams, oOutParams 
 
    Set oCtx = CreateObject(&quot;WbemScripting.SWbemNamedValueSet&quot;) 
    oCtx.Add &quot;__ProviderArchitecture&quot;, RegType 
 
    Set oLocator = CreateObject(&quot;Wbemscripting.SWbemLocator&quot;) 
    Set oReg = oLocator.ConnectServer(&quot;&quot;, &quot;root\default&quot;, &quot;&quot;, &quot;&quot;, , , , oCtx).Get(&quot;StdRegProv&quot;) 
 
    Set oInParams = oReg.Methods_(&quot;GetStringValue&quot;).InParameters 
    oInParams.hDefKey = RootKey 
    oInParams.sSubKeyName = Key5 
    oInParams.sValueName = Value 
 
    Set oOutParams = oReg.ExecMethod_(&quot;GetStringValue&quot;, oInParams, , oCtx) 
 
    ReadRegStr = oOutParams.sValue 
End Function 
rem----------------------------------------------------------------------------------------------------
rem===============================Чтение веток реестра в массив========================================
Function ReadEnumKey (RootKey1, Key6, RegType1) 
    Dim oCtx1, oLocator1, oReg1, oInParams1, oOutParams1  
    Set oCtx1 = CreateObject(&quot;WbemScripting.SWbemNamedValueSet&quot;) 
    oCtx1.Add &quot;__ProviderArchitecture&quot;, RegType1 
 
    Set oLocator1 = CreateObject(&quot;Wbemscripting.SWbemLocator&quot;) 
    Set oReg1 = oLocator1.ConnectServer(&quot;&quot;, &quot;root\default&quot;, &quot;&quot;, &quot;&quot;, , , , oCtx1).Get(&quot;StdRegProv&quot;) 
 
    Set oInParams1 = oReg1.Methods_(&quot;EnumKey&quot;).InParameters 
    oInParams1.hDefKey = RootKey1 
    oInParams1.sSubKeyName = Key6     
 
    Set oOutParams1 = oReg1.ExecMethod_(&quot;EnumKey&quot;, oInParams1, , oCtx1) 
 
    ReadEnumKey = oOutParams1.sNames  
End Function 
rem====================================================================================================

Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rem _____________________Запись логов__________________________________________________________________
Function writelog(byval strMessage)
    on error resume Next
&#039;    WScript.echo strMessage
&#039;    Exit Function
    err.clear    
    objFileLog.WriteLine strMessage
    if err.number&lt;&gt;0 then
        msgbox err.description
    end if
End Function
Rem ___________________Конец Запись логов______________________________________________________________
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (as07)]]></author>
			<pubDate>Thu, 26 Jul 2012 09:42:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=62046#p62046</guid>
		</item>
		<item>
			<title><![CDATA[Re: VBS запускается от 32-битного родительского потока, на x64. Реестр x3]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=61490#p61490</link>
			<description><![CDATA[<div class="codebox"><pre><code>x=CreateObject(&quot;WbemScripting.SWbemNamedValueSet&quot;)
x.Add &quot;__ProviderArchitecture&quot;, 64</code></pre></div><p>и т.д.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Wed, 11 Jul 2012 11:04:57 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=61490#p61490</guid>
		</item>
		<item>
			<title><![CDATA[VBS запускается от 32-битного родительского потока, на x64. Реестр x3]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=61477#p61477</link>
			<description><![CDATA[<p>Добрый день.<br />Есть скрипт. распрастраняется по Sccm, и получается что родительский поток запускается от x32, и получает значение ветки реестра x32 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node <br />Нужно что бы получил доступ к ветке реестра x64 HKEY_LOCAL_MACHINE\SOFTWARE\ , т.к. в ветке HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node нет нужных значений.</p><div class="codebox"><pre><code>Rem AutoCAD Fonts
rem Option Explicit
on error resume Next
Const HKEY_CURRENT_USER = &amp;H80000001
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const HKEY_USERS = &amp;H80000003 &#039;HKEY_USERS
Const ForWriting = 2
Const ForAppending=8
Const Create = True
Const Modal = True
Const TimeOut1 = &quot;0&quot;
Const TimeOut2 = &quot;5&quot;
Const OverwriteExisting = True
Const  EVENT_SUCCESS=0
Const  EVENT_ERROR=1
Const  EVENT_WARNING=2
Const  EVENT_INFORMATION=4
Rem ----------------------------------------------------------------------------------------------
&#039; путь к логам
strLogPath = &quot;\\server\LOGS\APP\Autodesk\Fonts\&quot;
strValueName = &quot;ProductName&quot;
strAcadLocation = &quot;Location&quot;
dim strLogMessage &#039;содержит текст протокола установки
Dim objShell
dim objWMIService
dim oRegistry
dim WshNetwork
dim objFSO
dim filename
strComputer=&quot;.&quot;
strLogMessage = &quot;&quot;
Set objShell = CreateObject(&quot;WScript.Shell&quot;)
Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;)
Set oRegistry=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; _
    strComputer &amp; &quot;\root\default:StdRegProv&quot;)
Set WshNetwork = CreateObject(&quot;WScript.Network&quot;)
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Rem Проверяем наличие входного параметра
strAction = &quot;&quot;
Set objArgs = WScript.Arguments
If WScript.Arguments.Count &gt; 0 Then
    strAction = UCase(Trim(WScript.Arguments(0)))
End If
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rem Открываем лог
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
strFileLogName = strLogPath &amp; WshNetwork.ComputerName &amp; &quot;.log&quot;
Rem Выполняем поиск в реестре записи о приложении
strKeyPath = &quot;SOFTWARE\Autodesk\AutoCAD&quot;

Err.clear
    Rem ----- Проверка Есть ли раздел---------------------------
        Err.clear
    value = objShell.RegRead(&quot;HKLM\SOFTWARE\Autodesk\&quot;)
          if err.number &lt;&gt; 0 then
        rem     MSGBOX &quot;Нет раздела HKLM\SOFTWARE\Autodesk\&quot;    
    else
        rem     MSGBOX &quot;Есть раздел&quot;    
        Set objFileLog = objFSO.OpenTextFile(strFileLogName, ForAppending, True )
        rem ---    Если есть то создаем лог------ 
        if err.number&lt;&gt;0 then
            MSGBOX &quot;Не удалось создать файл с протоколом &quot; &amp; strFileLogName &amp; &quot;: &quot; &amp; err.description
            wscript.Quit(-1)
        End If        
            writelog vbcrlf 
        writelog &quot;********************&quot;
        writelog Now
        writelog &quot;********************&quot;        
            writelog &quot;Копирование шрифтов в AutoCAD и DWG trueview Ищем Папки&quot;
        strWorkingDir = objShell.CurrentDirectory
        strFontPath=strWorkingDir&amp;&quot;\fonts&quot;
        rem MSGBOX strWorkingDir
        writelog &quot;Папка с шрифтами    &quot; &amp; strFontPath
        strKeyPathTru=&quot;SOFTWARE\Autodesk\AutoCAD&quot;
         FindANDCopyFont (strKeyPathTru)
        strKeyPathTru=&quot;SOFTWARE\Autodesk\DWG TrueView&quot;
         FindANDCopyFont (strKeyPathTru)    
     end if
Set objWMIService = Nothing
WScript.Quit
rem ================================== Основа =========================================================
sub FindANDCopyFont (strKeyPath)
oRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    rem +++++++++++++ Ищем Все ключи реестра в разделе ++++++++++++++++ 
      For Each subkey In arrSubKeys    
        key = strKeyPath &amp; &quot;\&quot; &amp; subkey
        oRegistry.EnumKey HKEY_LOCAL_MACHINE, key, arrSubKeys1
        For Each subkey1 In arrSubKeys1
            key1=key &amp; &quot;\&quot; &amp; subkey1
            writelog vbTab &amp; key1
            strValueNameValue=&quot;&quot;
            strAcadLocationeValue=&quot;&quot;
            oRegistry.GetStringValue HKEY_LOCAL_MACHINE,key1,strValueName,strValueNameValue            
            oRegistry.GetStringValue HKEY_LOCAL_MACHINE,key1,strAcadLocation,strAcadLocationeValue
            rem определяем путь шрифтов
            if strValueNameValue &lt;&gt;&quot;&quot; then        
                strAcadLocationeValue=strAcadLocationeValue&amp;&quot;\Fonts&quot;
                writelog vbTab &amp; strValueNameValue &amp; vbtab &amp; strAcadLocationeValue
                Set objFolder = objFSO.GetFolder(strFontPath)
                Set colFiles = objFolder.Files
                rem ------------ Проверка есть ли в папке шрифт или нет и его копирование -------------------------------     
                For Each objFile in colFiles
                    filename=strAcadLocationeValue &amp; &quot;\&quot; &amp; objFile.Name         
                    if  (objFSO.FileExists(filename))  Then
                          writelog vbTab &amp; objFile.Name &amp;&quot;  Файл  существует  в папке &quot; &amp; filename             
                    else              
                          writelog vbTab &amp; &quot;Файл не существует копируем в &quot; &amp; filename
                        objFSO.CopyFile (strFontPath &amp; &quot;\&quot; &amp; objFile.Name) , strAcadLocationeValue &amp;&quot;\&quot; , OverwriteExisting
                    end if              
                Next
            end if    
          next          
      Next    
end sub

rem ===================================================================================================



Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rem _____________________Запись логов__________________________________________________________________
Function writelog(byval strMessage)
    on error resume Next
&#039;    WScript.echo strMessage
&#039;    Exit Function
    err.clear    
    objFileLog.WriteLine strMessage
    if err.number&lt;&gt;0 then
        msgbox err.description
    end if
End Function
Rem ___________________Конец Запись логов______________________________________________________________
Rem +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (as07)]]></author>
			<pubDate>Tue, 10 Jul 2012 04:31:23 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=61477#p61477</guid>
		</item>
	</channel>
</rss>
