Client Management Suite

 View Only
  • 1.  Altiris 6 SWD and x64 Scripts

    Posted Oct 25, 2011 08:53 AM

    Hello,

    I have a problem with Altiris 6 Software Deliery which is installed on x64 Machines.

     

    When I run a vbscipt on a x64 machine to checks a registry key in HKLM\Software it reads the HKLM\Software\Wow6432Node Key.

     

    Example script:

     

     Set WshShell = WScript.CreateObject("WScript.Shell")
     On Error Resume Next
     
     WSHShell.RegRead "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired\"
        If Err.Number<>0 Then
        Err.Clear
        KeyExists=False
        wscript.echo "No reboot is required"
        Else
        KeyExists=True
        wscript.echo "Reboot required"
        End If
     On Error GoTo 0

     

    The sciprt checks if the key "RebootRequired" exist. If I run the scipt by hand it works fine on x86 and x64 machines.

    But if I run this scipt with Software Delivery on a x64 system it always tries to read the key in Wow6432.

    Same Problem with batch files.

    If you run a batch file with SWD to check the Processor Architecture (%Processor_Architecture%) it always gives you back that you have a x86 CPU installed.

     

    For batch files I found an easy workaroud:

     

    :Get Environment
    set Registry_Path="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
    Set Registry_Key=/v "PROCESSOR_ARCHITECTURE"

    FOR /F "tokens=3 delims=     " %%A IN ('REG QUERY %Registry_Path% %Registry_Key% ') DO SET PROCESSOR=%%A

    echo %PROCESSOR%

    If %PROCESSOR% == AMD64 goto x64
    IF %PROCESSOR% == x86   goto x86
    exit

    :x86
    setup_x86.exe
    exit

    :x64
    setup_x64.exe
    exit

     

    But now it need to check a registry key, like in the exapmle vbscipt. Is there any solution for that?

    Thanks a lot,



  • 2.  RE: Altiris 6 SWD and x64 Scripts

    Posted Oct 25, 2011 09:59 AM

    You can execute your vbs using the 64bit version of wscript:

    if exist "%WINDIR%\sysnative\wscript.exe" "%WINDIR%\sysnative\wscript.exe" <your.vbs>

    By the way, there is a new environment variable if you run a 32bit shell in a 64bit WOW environment:

    PROCESSOR_ARCHITECTURE=x86

    PROCESSOR_ARCHITEW6432=AMD64



  • 3.  RE: Altiris 6 SWD and x64 Scripts

    Posted Oct 25, 2011 10:59 AM

    Thanks for your answer.

     

    Unfortunately I can´t find the folder “sysnative” on my system.

    I have

    ·         C:\Windows\SysWOW64\wscript.exe

    ·         C:\Windows\System32\wscript.exe

    If I run the script manually it uses the x64 environment with the system32\wscipt.exe and the x86 environment with the SysWOW64\wscript.exe

    It always uses the x86 environment if I run it with SWD.



  • 4.  RE: Altiris 6 SWD and x64 Scripts
    Best Answer

    Posted Oct 25, 2011 11:42 AM

    Its not a real folder. Run

    "%WINDIR%\sysnative\wscript.exe" <your.vbs>

    on a 64bit OS and it will work.

    32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access. This mechanism is flexible and easy to use, therefore, it is the recommended mechanism to bypass file system redirection. Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one.

    http://msdn.microsoft.com/en-us/library/aa384187%28v=vs.85%29.aspx

    You didnt even try ;)



  • 5.  RE: Altiris 6 SWD and x64 Scripts

    Posted Oct 25, 2011 11:53 AM

    Awesome it works. Thanks a lot :-)