Situation:
You want to run different task (application install / registry edition / copy to another path / …) depends on processor architecture. You must to determinate that what is the maximum addressable length of target processor so in short: It is 32-bit (x86) or 64-bit (x64) processor?
Solution:
Here you can find a working windows batch which will run your declared command depends on processor architect.
title CH-E-MISTRY cd /d %~dp0 rem Created by Mikáczó Péter (solve CPU-bit detection task) rem Theory of operation: rem IF PROCESSOR_ARCHITECTURE == amd64 OR rem PROCESSOR_ARCHITEW6432 == amd64 THEN rem // OS is 64bit rem ELSE rem // OS is 32bit rem END IF - QUIT if %PROCESSOR_ARCHITECTURE% == x86 ( goto :wow64 ) else ( goto :x64 ) :wow64 if %PROCESSOR_ARCHITEW6432% == NOT DEFINED THEN ( goto :x86 ) else ( goto :x64 ) :x86 echo The Operating System is 32bit version setupx86HUN.cmd goto :exit :x64 echo The Operating System is 64bit version setupx64HUN.cmd goto :exit :exit quit
How to use it:
- The name of it is not important, but the extension of it must to be .cmd
- You must to edit two thing for your need: The task what you must to start in x86-case (setupx86HUN.cmd) & in x64-case (setupx64HUN.cmd).
Of course you can embed more batch, like in our case (the main batch start an another batch as task).