Can I check to see if current machine is running 64bit OS or 32bit OS inside a batch file?
EDIT:
Found this online and it is good enough to me now:
Can I check to see if current machine is running 64bit OS or 32bit OS inside a batch file?
EDIT:
Found this online and it is good enough to me now:
The correct way, as SAM write before is:
but with /v "Identifier" a little bit correct.
This is the correct way to perform the check as-per Microsoft's knowledgebase reference ( http://support.microsoft.com/kb/556009 ) that I have re-edited into just a single line of code.
It doesn't rely on any environment variables or folder names and instead checks directly in the registry.
As shown in a full batch file below it sets an environment variable OS equal to either 32BIT or 64BIT that you can use as desired.
Run the below in the command prompt:
Start -> Run -> Type
cmd
and enter the command below in the resulting black box:reference http://support.microsoft.com/kb/556009
This is a one-liner that will have
%errorlevel%
of 0 for 64-bit, 1 for non-64-bit. I can't vouch for it working on all versions of Windows, but demonstrates one method for determining it. You can add multiplefindstr
queries if you know all the possibilities to look for.set | findstr /i processo.*64 > nul 2>&1
Basically, you're dumping the environment variables, and using a regular expression to search for something that has "
processo
" + "64
" somewhere in its line. The piping is just to suppress the matching lines. If I changed it toset | findstr /i processo.*64 > nul 2>&1
on my current rig, this would be the result:This is a one-liner to see if your processor is a 64-bit AMD
set | findstr /i processo.*amd.*64 > nul 2>&1
You can take these as a starting point and refine them for your requirements. I ended up using this over known environment variable names due to it being more reliable across different major versions of Windows that I was working with.