Detect Windows Server version 32/64-bit in CLI
What's the best and quickest way to detect whether you're running a 32 or 64-bit version of Windows Server from the command line?
(Cygwin is installed)
Solution 1:
A slightly quicker way would be to check for the existence of the %ProgramFiles(x86)% directory. If it exists then you're running 64-bit, if it doesn't exist then you're running 32-bit.
Quick one-liner:
if exist "%ProgramFiles(x86)%" echo 64-bit
That will output 64-bit
if the directory exists. That would fail, though, if it didn't exist as a variable but it did exist as a directory (as %ProgramFiles(x86)%).
You can also use the find tool to have a more accurate way to determine bitness.
set | find "ProgramFiles(x86)"
or using the systeminfo
command previously
systeminfo | find /I "System type"
(included the /I
to work across XP/2003/2008/etc)
Solution 2:
How about:
echo %PROCESSOR_ARCHITECTURE%
This will return x86 on 32-bit systems and AMD64 (or IA64) on 64-bit systems.