thedexmonster Posted December 21, 2011 Share Posted December 21, 2011 Hello, I'm trying to install software on particular machines based on operating system and architecture. I've ran into a wall with this bit of code. For some reason it wont set the variable arch when ran remotely.SYSTEMINFO | FIND "System Type" > C:\sysType.txtFOR /F "usebackq delims=: tokens=3" %%c IN (C:\sysType.txt) DO SET arch=%%cECHO %arch% | FIND "86" > NULIF %ERRORLEVEL% == 0 (GOTO VISTA) ELSE (GOTO 64)I also use this and it works fine:SYSTEMINFO | FIND "OS Name" > C:\osName.txtFOR /F "usebackq delims=: tokens=2" %%c IN (C:\osName.txt) DO SET vers=%%cvers always has a proper value. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
Mr_Smartepants Posted December 21, 2011 Share Posted December 21, 2011 (edited) Can we assume the host is Windows-based? How about a registry scan instead?:OS-checkFOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') DO SET build=%%Bif /I "%build%"=="2600" set OSbuild=XPif /I "%build%"=="6000" set OSbuild=Vistaif /I "%build%"=="6001" set OSbuild=Vistaif /I "%build%"=="6002" set OSbuild=Vistaif /I "%build%"=="7600" set OSbuild=Win7if /I "%build%"=="7601" set OSbuild=Win7if /I "%build%"=="7602" set OSbuild=Win7FOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') DO SET prodname=%%BSET ARCH=86IF EXIST "%SystemRoot%\SysWOW64" set ARCH=64The above code assumes a 32-bit host unless the syswow64 folder exists, then 64-bit.http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.htmlScanning systeminfo is kind of clunky when lots of environment variables exist to help you.%OS%%PROCESSOR_ARCHITECTURE%%PROCESSOR_IDENTIFIER% Edited December 21, 2011 by Mr_Smartepants Quote Link to comment Share on other sites More sharing options...
thedexmonster Posted December 22, 2011 Author Share Posted December 22, 2011 http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.htmlScanning systeminfo is kind of clunky when lots of environment variables exist to help you.%OS%%PROCESSOR_ARCHITECTURE%%PROCESSOR_IDENTIFIER%This link comes up not found.Also, I need to know the version of windows installed, not the type of cpu installed. I'm running windows 7 64bit, %os% = Windows_NT. Doesn't help. Quote Link to comment Share on other sites More sharing options...
thedexmonster Posted December 22, 2011 Author Share Posted December 22, 2011 IF EXIST "%SystemRoot%\SysWOW64" set ARCH=64The above code assumes a 32-bit host unless the syswow64 folder exists, then 64-bit.This I like and thank you! I hadn't thought of that. Quote Link to comment Share on other sites More sharing options...
myselfidem Posted December 26, 2011 Share Posted December 26, 2011 This link comes up not found.Also, I need to know the version of windows installed, not the type of cpu installed. I'm running windows 7 64bit, %os% = Windows_NT. Doesn't help.I think you can find more info at this link:http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.htmlhttp://www.windows-commandline.com/2010/11/system-information-systeminfo-command.htmlHowever with my localized Windows 7 French version I must use French language inside the command prompt, like this example:C:\>SYSTEMINFO | FINDSTR /C:"Version du système"C:\>systeminfo | findstr /C:"Version du système"Version du système: 6.1.7601 Service Pack 1 version 7601You also can use:C:\>SYSTEMINFO /FO LIST >C:\SysInfo.txtTo read all informations inside the text file and select the one you need to use ! Quote Link to comment Share on other sites More sharing options...
linkstat Posted June 22, 2014 Share Posted June 22, 2014 Hello!talking about necroposting...But, doesn't matter. Here we go: Like many, every once in a while I usually run into the problem that Windows does not have a standardized or uniform way to provide information about operating environment... at least not in the Batch world.So, for deal with this issue, I decided to create me a routine that allows me to identify the environment variables in a unified way, for all my batch's scripts... and I believe to have succeeded fairly well, but... I'm not entirely satisfied with the results when the target OS is a Windows below v6.0 (this is XP, 2003, 2000, etc.). So, i decided to share and ask for something well experienced in batch scripting, for a little help of how to improve the script. Link to the script: here Greetings! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.