access to 64bit registry node with a wscript.exe*32 executed vb script

Author Message
pd2k

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 4/6/2010
  • Status: offline
access to 64bit registry node with a wscript.exe*32 executed vb script Wednesday, November 10, 2010 1:06 AM (permalink)
0
hi,
i would like to distribute software via sccm.
The software is a vb script which reads some local information of the client machine.
The script is executed trough wscript.exe in 32bit mode. On 64bit machines I have no access to the 64bit registry node because the script is executed through wscript.exe*32.
There are lots of problems (for example the programs path variable).
Is there any possibility to access the 64 bit registry node with a 32bit wscript application?
 
Thanks
 
#1
    john7a8

    • Total Posts : 580
    • Scores: 35
    • Reward points : 0
    • Joined: 1/25/2010
    • Location: Orlando, FL
    • Status: offline
    Re:access to 64bit registry node with a wscript.exe*32 executed vb script Wednesday, November 10, 2010 1:51 AM (permalink)
    0
    Have you checked MSDN on WOW64 Implementation Details?
     
    http://msdn.microsoft.com...384274%28VS.85%29.aspx
     
    #2
      pd2k

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 4/6/2010
      • Status: offline
      Re:access to 64bit registry node with a wscript.exe*32 executed vb script Wednesday, November 10, 2010 3:07 AM (permalink)
      0
      I've read it but I don't know how it should help solving my problem?!
       
      #3
        rasimmer

        • Total Posts : 2363
        • Scores: 163
        • Reward points : 0
        • Joined: 3/19/2009
        • Location: Cedar Rapids, IA
        • Status: offline
        Re:access to 64bit registry node with a wscript.exe*32 executed vb script Wednesday, November 10, 2010 3:33 AM (permalink)
        0
        Access to the registry is independent of which engine is executed.  A  64-bit system is just like a 32-bit, it uses the same registry keys, folder locations (i.e. C:\Program Files, C:\Windows\System32).  The difference is that 64-bit systems have a 32-bit sub-system to enable you to run 32-bit apps in the 64-bit OS.  So, if there is a 32-bit application installed then it would be installed in C:\Program Files (x86).  If you have a script to read a value for some 32-bit software HKLM\Software\MyCompanySoftware\Parameter, then it would be located in HKLM\Software\Wow6432Node\MyCompanySoftware\Parameter in the 64-bit system.  There is no "access" difference, just location difference.
         
        The biggest caveat that I have found (and has been discussed on the forum) is ODBC, which are the drivers used to access databases.  The drivers are 32-bit drivers, so in order to access the driver you need to execute the script with the 32-bit CScript\WScript (C:\Windows\SysWow64) engine.
        <message edited by rasimmer on Wednesday, November 10, 2010 3:35 AM>
         
        #4
          pd2k

          • Total Posts : 4
          • Scores: 0
          • Reward points : 0
          • Joined: 4/6/2010
          • Status: offline
          Re:access to 64bit registry node with a wscript.exe*32 executed vb script Wednesday, November 10, 2010 8:23 PM (permalink)
          0
          Ok i can access the 32bit node from a 64bit application by using the wow6432Node. But how should my 32bit application know, that there's a 64bit node?
          My 32bit application uses the keys from wow6432node (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node) and it seems to be HKEY_LOCAL_MACHINE\SOFTWARE for it.
          So there is no difference to the "normal" 64 bit node and i can't access it, can i?
          Which path sould i adress instead of HKEY_LOCAL_MACHINE\SOFTWARE to get the 64bit values?
           
          I found an MSDN article about accessing a different registry node on:
          http://msdn.microsoft.com/en-us/library/aa384129.aspx
           
          But is this the only possibility?
          <message edited by pd2k on Wednesday, November 10, 2010 8:37 PM>
           
          #5
            rasimmer

            • Total Posts : 2363
            • Scores: 163
            • Reward points : 0
            • Joined: 3/19/2009
            • Location: Cedar Rapids, IA
            • Status: offline
            Re:access to 64bit registry node with a wscript.exe*32 executed vb script Thursday, November 11, 2010 2:58 AM (permalink)
            0
            You have to detect the architecture and you logic will need to be different for 32\64-bit.  Here is an example of a script that will search for installed software on a system and if it's a 64-bit system then it will search both software keys for the software:
             
            Const HKLM = &H80000002
            Set objWSHSHell = WScript.CreateObject("WScript.Shell")
            Set objReg = GetObject("winmgmts:!root/default:StdRegProv")
            If Is64Bit = True Then
                arrSearchKeys = Array("SOFTWARE\Wow6432Node", "SOFTWARE")
            Else
                arrSearchKeys = Array("SOFTWARE")
            End If
            For Each strKey in arrSearchKeys
                Call Uninstall_Software("UltraEdit 14.20", strKey)
            Next
            Function Uninstall_Software(search_string, search_key)
             'On Error Resume Next
                strUninstallKey = search_key & "\Microsoft\Windows\CurrentVersion\Uninstall"
             objReg.EnumKey HKLM, strUninstallKey, arrSubKeys
             For Each strSubKey In arrSubKeys
                 objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "DisplayName", strDispName
                objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "DisplayVersion", strVer
                    objReg.GetStringValue HKLM, strUninstallKey & "\" & strSubKey, "UnInstallString", strUnInstall
                    If Instr(Ucase(strDispName), UCase(search_string)) Then
                        strUninstall = strUninstall & " /qn /norestart"  'Add any switches needed
                        WScript.Echo "Running command:  " & strUninstall
            '            errReturn = objWSHShell.Run(strUnInstall, 0, True)
            '            If errReturn = 0 Then
            '                'Successfully uninstalled
            '            Else
            '                'Removal failed
            '            End If
                    End If   
             Next
            End Function
            Function Is64Bit()
                Is64Bit = False
                Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)
                Dim objOS
                For Each objOS In colOS
                    If objOS.AddressWidth = 64 Then Is64Bit = True
                Next
            End Function
             
            #6
              Meitzi

              • Total Posts : 1
              • Scores: 0
              • Reward points : 0
              • Joined: 12/12/2011
              • Status: offline
              Re:access to 64bit registry node with a wscript.exe*32 executed vb script Monday, December 12, 2011 1:19 AM (permalink)
              0
              Accessing 64bit registry using 32bit application is difficulty.
               
              You need open registry using special flags in API call.
              http://msdn.microsoft.com/en-us/library/windows/desktop/ms724072(v=vs.85).aspx
               
               
              In general, use 32bit application to configure 32bit application.
              Use 64bit application to configure 64bit application and thats it.
               
              So why dont you use 64bit wscript in x64 systems?
              Other way is use powershell.
              <message edited by Meitzi on Monday, December 12, 2011 1:31 AM>
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9