/build/static/layout/Breadcrumb_cap_w.png

Platform architecture and OS detection script

Deploy software through KACE K1000 is really easy but how we can deploy a software that has multiple installers each for every platform (Windows XP & Windows 7) and architecture (x64 & x86)?

I realized a script that helps you to detect the architecure and the platform.

 
@echo off
if %PROCESSOR_ARCHITECTURE% ==x86 (
goto :x86
)
else (
goto :x64
)

:x86
if exist "C:\Users\All Users\ntuser.dat" goto win7x86
if exist "C:\Documents and Settings\All Users\ntuser.dat" goto winxpx86
goto osnotdetected

:win7x86
REM Place here the installer command for Windows 7 or Vista 32bit
SetupForWin7x86.exe /S
goto :eof

:winxpx86
REM Place here the installer command for XP 32bit
SetupForXPx86.exe /S
goto :eof

:x64
if exist "C:\Users\All Users\ntuser.dat" goto win7x64
if exist "C:\Documents and Settings\All Users\ntuser.dat" goto winxpx64
goto osnotdetected

:win7x64
REM Place here the installer command for Windows 7 or Vista 64bit
SetupForWindows7x64.exe /S

:winxpx64
REM Place here the installer command for Windows XP 64bit
SetupForWindowsXPx64.exe /S
goto :eof

:osnotdetected
Echo I have no idea what OS is this one
REM The end

Caveats:

  • The script is given AS IS. You need to test it and adapt it to you needs before to adopt it.
  • The script bases the decision about the OS (XP or Vista/7) based on the presence of a system file in a specifc path: if your OS language is not English you may need to refurbish it a bit... 

Comments

  • Not bad - you may also want to consider querying the value of HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion to determine the OS. The value is 6.1 for Windows 7, 6.0 for Vista and 5.2 for XP. As an FYI, 2008 and Vista share the same version, and 7/2008 R2 do as well. To differentiate, you can look at the InstallationType key within the same hive, which is Client/Server respectively - drose23 11 years ago
    • Hello thanks for the suggestion. How can I use the IF in the batch with the REG command? I may need to rewrite all in VBS but the idea was to keep it simple and supported on all the Microsoft OS. Thanks!! Marco - StockTrader - StockTrader 11 years ago
  • Off the top of my head, something like this may work. May be more efficient ways of doing it as well....


    @echo off

    Set RegQry=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    REG.exe Query %RegQry% > clientversion.txt
    Find /i "6.1" < clientversion.txt > StringCheck.txt
    If %ERRORLEVEL% == 0 (

    DO STUFF HERE THAT WOULD BE DONE ON WINDOWS 7/R2

    goto exit

    ) ELSE (

    DO STUFF HERE THAT WOULD BE DONE ON WINDOWS XP, ETC

    goto exit
    )

    :exit

    Expand on the functionality or text within the find string if you want to search for different things (i.e. combine search for Client vs. Server) - drose23 11 years ago
    • Interesting!! Thanks & Regards. StockTrader - StockTrader 11 years ago
  • No problem. Hope it helps. - drose23 11 years ago
    • And apologies for not using code tags, didn't see a way of doing that in the reply view - drose23 11 years ago
  • thanks for suggestion - mark_lawrence007 11 years ago
This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ