I need to check Office for 64 bit or 32 bit version. In a batch file, is there a way to get the following to work considering the Bigfix agent is 32 bit?
:: Office 2016/365 (16.0)
reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" /v Bitness >nul 2>&1
if %errorlevel% equ 0 (
for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" /v Bitness ^| findstr /i "Bitness"') do (
if /i "%%b"=="x64" (
echo Microsoft Office is 64-bit (MSI - 16.0).
) else (
echo Microsoft Office is 32-bit (MSI - 16.0).
)
goto :end
)
)
Yes, just be sure to disable wow64 redirection. Since the action will not interact with the desktop interface, you'll also need to redirect the output to a file. The following should work
createfile until END_OF_FILE_MARKER
:: Office 2016/365 (16.0)
reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" /v Bitness >nul 2>&1
if %errorlevel% equ 0 (
for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" /v Bitness ^| findstr /i "Bitness"') do (
if /i "%%b"=="x64" (
echo Microsoft Office is 64-bit (MSI - 16.0).
) else (
echo Microsoft Office is 32-bit (MSI - 16.0).
)
goto :end
)
)
END_OF_FILE_MARKER
delete office.cmd
move __createfile office.cmd
action uses wow64 redirection false
waithidden cmd.exe /c office.cmd > c:\output.txt 2>&1
Outside of a batch file/actionscript, you should be able to check the 'Bitness' in Relevance by using the 'native registry' instead of 'registry' inspector, i.e.
values "Bitness" of keys "HKLM\Software\Microsoft\Office\16.0\Outlook" of native registry
I assume since you posted here, you will run the batch file from BigFix? This means it will run as a 32 bit app.
We use this in our batch files...
:checkarch
IF NOT "%PROCESSOR_ARCHITECTURE%"=="x86" SET InstallArch=64bit
IF "%PROCESSOR_ARCHITEW6432%"=="AMD64" SET InstallArch=64bit
IF "%InstallArch%"=="64bit" SET Wow6432Node=\Wow6432Node
GOTO :EOF
I use the SWD. I put the redirection in the following position and got: “Command failed (Override keyword is unknown for this command.) override action uses wow64 redirection false”.
Tried moving the redirection before the override wait, and that did not work either, but no error.
If you wanted to avoid actionscript/batch and use a property to capture/record the bitness, perhaps a pure relevance option exists, something like
Q: (if (exists it) then (if (it as lowercase = "x64") then ("Microsoft Office is 64-bit (MSI - 16.0)") else ("Microsoft Office is 32-bit (MSI - 16.0)")) else ("Not Installed")) of (concatenation "" of (values "Bitness" of keys "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" of (x64 registry ; registry) as string)) A: Microsoft Office is 32-bit (MSI - 16.0) T: 0.228 ms I: singular string
I don’t think this works because if Office 32 bit is installed, then the wow64 redirection false will be wrong. I think I am going to have to have two separate fixlets: one for Office 64 bit and one for Office 32 bit. I know it is possible to do it in one fixlet, but it would all have to be in action script.
Sure, that may be the case; it's a little difficult for me as I don't have a working example right now from which to work.
The original batch file you posted, I assume already works in both cases; but it only does a single registry query, which by default I would assume is using the native/x64 registry path
I agree Jason. Using action script and having one fixlet would be preferable, but I have not gotten comfortable coding the downloads since I always use the SWD.
I’m not clear on what your exact use case is to need a CMD, but just to share another thought, if I were needing to download and execute something depending on the Office application bitness, I’d be thinking of using a prefetch block where the download URL is set based on the dynamic detection of the registry data as a static filename, then execute it (and you can also based the wow64 redirection of the execution of the file, if applicable, based on the detected bitness).
By using a prefetch block, it avoids downloading both files for every endpoint, where only 1 is needed so saves bandwidth (e.g say it was a 1gb file for x86 AND 1gb for x64)
begin prefetch block
parameter "OfficeBitness" = "{(concatenation "" of (values "Bitness" of keys "HKLM\SOFTWARE\Microsoft\Office\16.0\Outlook" of (x64 registry ; registry) as string))}
if {(parameter "OfficeBitness") = "x86"}
add prefetch item name=something.exe sha1=500d1ad82b2a9e532e251e94d31de3f8a5cf4174 size=123456789 url=http://your.url.com/x86file.exe
elseif {(parameter "OfficeBitness") = "x64"}
add prefetch item name=something.exe sha1=fba3e0dfa6c8985b41bcbe3594ee941ce98b740c size=123456788 url=http://your.url.com/x64file.exe
endif
end prefetch block
action uses wow64 redirection {(parameter "OfficeBitness") = "x64"}
waithidden __download\something.exe /qn /norestart
I’m not sure if this helps, I have a property that returns x64 or x86 or no C2R, depending on 64-bit, 32-bit or none installed.
if exists key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" of native registry then (value "Platform" of it as string) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" of native registry else "no C2R"
No the issue is whether the Bigfix action script is running in 32 or 64 bit mode. By default it runs in 32 bit mode. By using the action script command “action uses wow64 redirection false”, the action will run in 64 bit mode. SLB above had the answer, but it requires action script not generated by the SWD.