Saturday 1 June 2019

64 bit - 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)



Answer



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)


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...