How can I create a batch file that tells if an installed program (.exe) is 32 or 64 bit?
Sometimes you can tell based on the which folder the program.exe file is in.
If the installed program is 32 bit it will show up in the Program Files (x86)folder. If the file is 64 bit it will show up in the Program Files folder.
But this is not always the case...
For example Google Chrome always shows up in Program Files x86
But the version on my computer is 64 bit:
How can I reference chrome.exe for example and have batch tell me if its 64 or 32 bit?
This script will do the trick: Identify 16-bit, 32-bit and 64-bit executables with PowerShell
If you call this from within powershell: "Source" (aka) run the script once to get the function into memory then you can just use it..
. .\Get-ExecutableType.ps1 #sources the script
Get-ExecutableType -Path C:\Windows\System32\notepad.exe #runs the function
To call this script "the easy way" from a batch file, add this to the bottom of the script after the last curly brace:
Get-ExecutableType -Path $args[0]
And call it like this:
powershell -command "& .\Get-ExecutableType.ps1 X:\Your.exe"
Other options:
You can also use the added "batch lines" to call it from powershell without sourcing the file first.
You can also use silly powershell syntax to call the function without sourcing the file first. powershell.exe -c "& { [script_file] [params] ; [function_name] }"