I posted a while back about detecting Windows Operating System Versions – I had some help and inspiration from another site / blogger. At the time I was only working with 32 bit versions of Windows but now 64 bit versions have been rolling in the door :)
Reference for the command I use (wmic OS get OSArchitecture) is here at Petri.co.
Time to adjust my batch file to detect architecture type. So without further adieu…
Those unfamiliar with batch files here’s a small legend of my code:
:: <- The double colon means a comment, you can also say ‘rem’ to remark out the line but the :: seems cleaner to me
@echo off <- That turns off showing text / commands on the screen and will only show things you ‘echo’
* In troubleshooting I often ‘echo’ my error levels so I know what the result is, you’ll see that below
********
@echo off
:arch
echo.
echo Finding your processor architecture…
systeminfo | findstr /C:”Microsoft Windows 7 Professional”
echo.
:: Here’s some echo’ing going on so I can see the errorlevels, uncomment to see them
:: If it’s “Microsoft Windows 7 Professional” errorlevel = 0 for a true!
:: If it’s not “Microsoft Windows 7 Professional” errorlevel = 1 for a false!
:: echo Errorlevel is…
:: echo.
:: echo %errorlevel%
IF %ERRORLEVEL% EQU 0 goto ArchDetect
IF %ERRORLEVEL% EQU 1 goto XP
::If it’s not Windows 7 (in my environment it’s 32 bit XP so it moves on to the :XP section below
:: If it’s Windows 7 it goes to it goes to :ArchDetect
:ArchDetect
:: Get OS Architecture type of Windows 7 Pro
wmic OS get OSArchitecture | findstr /C:”32-bit”
:: echo Errorlevel is…
:: echo.
echo %errorlevel%
IF %ERRORLEVEL% EQU 0 goto 7
IF %ERRORLEVEL% GTR 0 goto 7_64
:7
echo.
echo You’ve got 32 bit Windows 7
echo You’d put your batch file commands for 7-x32 here…
goto end
:7_64
echo.
echo You’ve got 64 bit Windows 7
echo You’d put your batch file commands for 7-x64 here…
goto end
:XP
echo.
echo You’ve got Windows XP
echo You’d put your batch file commands for XP here…
goto end
:end
pause
********
So put all that code into a file called something.bat <- Name it whatever you want as long as the file extension is .bat. You can double click it or run it from the command line and see what it does :)
Here’s my output when I run it from a command prompt on my current machine:
C:\temp\>c:\temp\findst2.bat
Finding your processor architecture…
OS Name: Microsoft Windows 7 Professional
32-bit
0
You’ve got 32 bit Windows 7
You’d put your batch file commands for 7-x32 here…
Press any key to continue . . .
Hi! Do you know if they make any plugins to protect against
hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any recommendations?
Yes it’s called wordfence and there are geoip block plugins that allow you to block countries. Unfortunately I didn’t block Germany where you posted your comment from! :P
What’s Happening i am new to this, I stumbled upon this I have found It absolutely useful and it has aided me out
loads. I’m hoping to give a contribution & aid other users like its helped me.
Good job.
Thank you pal.
That did my job perfectly.