64 Bit Support on Windows [W]

The opsi-script is a 32 bit program. In order to make it easy for 32 bit programs to run on 64 bit systems there are special 32 bit areas in the registry as well in the file system. Some accesses from 32 bit programs will be redirected to these special areas to avoid access to areas that reserved for 64 bit programs.

A access to c:\windows\system32 will be redirected to c:\windows\syswow64.

But a access to c:\program files will be not redirected to c:\program files (x86).

A registry access to [HKLM\software\opsi.org] will be redirected to [HKLM\software\wow6432node\opsi.org].

Table 1. Registry Redirection basic rule

Key

Windows Server 2008 R2, Windows 7, and Newer

HKEY_LOCAL_MACHINE\SOFTWARE

Redirected

HKEY_CURRENT_USER\SOFTWARE

Shared

This basic rule you should keep in mind.
Looking to the details it is more complicated. A hive that is redirected may have a sub hive that is not redirected (shared). And these hives may have sub hives there are redirected again.

Table 2. Registry Redirection more details

Key

Windows Server 2008 R2, Windows 7, and Newer

HKEY_LOCAL_MACHINE\SOFTWARE

Redirected

HKEY_LOCAL_MACHINE\SOFTWARE\Classes

Shared

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID

Redirected

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\DirectShow

Redirected

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface

Redirected

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Media Type

Redirected

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MediaFoundation

Redirected

HKEY_CURRENT_USER

Shared

HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID

Redirected

HKEY_CURRENT_USER\SOFTWARE\Classes\DirectShow

Redirected

HKEY_CURRENT_USER\SOFTWARE\Classes\Interface

Redirected

HKEY_CURRENT_USER\SOFTWARE\Classes\Media Type

Redirected

HKEY_CURRENT_USER\SOFTWARE\Classes\MediaFoundation

Redirected

This table does still not show the complete situation. The complete table with all details you will find here:
https://learn.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow

Therefore opsi-script installs as 32 bit program scripts, that run on 32 bit system fine, on 64 bit system correct without any change.

For the installation of 64 bit programs some constants like %ProgramFilesDir% returns the wrong values. Therefore we have since opsi-script 4.10.8 some new features:

Normally you may (and should) tell explicit to which place you want to write or from where you want to read. Here we have three variants:

32

explicit 32 bit

64

explicit 64 bit; if not on a 64 bit system like 'sysnative'

SysNative

according to the architecture of the operating system on which the script runs

Following this idea, we have some additional constants:

Table 3. Constants
Constant 32 Bit 64 Bit

%ProgramFilesDir%

c:\program files

c:\program files (x86)

%ProgramFiles32Dir%

c:\program files

c:\program files (x86)

%ProgramFiles64Dir%

c:\program files

c:\program files

%ProgramFilesSysnativeDir%

c:\program files

c:\program files

%ProgramFilesDir%

you should avoid this in future. Works just like %ProgramFiles32Dir%.

%ProgramFiles32Dir%

should be used in the context of installing 32 bit Software.

%ProgramFiles64Dir%

should be used in the context of installing 64 bit Software.

%ProgramFilesSysnativeDir%

should be used if you need architecture specific information.

For a reading access to the different areas of registry and filesystem we have now the following new functions:

  • GetRegistrystringvalue32, GetRegistrystringvalue64, GetRegistrystringvalueSysNative (recommendation: use getRegistryValue)

  • getRegistryKeyList32, getRegistryKeyList64, getRegistryKeyListSysNative (recommendation: use getRegistryKeyList)

  • getRegistryVarList32, getRegistryVarList64, getRegistryVarListSysNative (recommendation: use getRegistryVarList)

  • getRegistryVarMap32, getRegistryVarMap64, getRegistryVarMapSysNative (recommendation: use getRegistryVarMap)

  • FileExists32, FileExists64, FileExistsSysNative

  • getFileInfoMap32, getFileInfoMap64, getFileInfoMapSysNative

The following functions have the possibility to control the access mode by a parameter (the default is here sysnative):

  • getRegistryValue

  • RegKeyExists

  • RegVarExists

  • powershellCall

  • FileOrFolderExists

  • DirectoryExists

  • listFiles

Using the following functions you have to give the access mode by a parameter:

  • getRegistryKeyList

  • getRegistryVarList

  • getRegistryVarMap

A simple call to Registry-section results in writing to the 32 bit registry regions. Also a simple call to Files-section results in writing to the 32 bit file system regions.

For 'Registry', 'Files' and Winbatch sections we have now the additional calling options:

  • /32Bit
    This is the default. Any access will be redirected to the 32 bit regions.

  • /64Bit
    Any access will be redirected to the 64 bit regions. If there are no 64 bit regions the architecture specific regions will be used.

  • /SysNative
    Any access will be redirected to the architecture specific regions

For ShellScript and Execwith you have to keep in mind that any modifiers has to separated by the keyword winst.
Example:

ShellScript_do_64bit_stuff winst /64Bit