Jump to content

Recommended Posts

Posted

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.txt

FOR /F "usebackq delims=: tokens=3" %%c IN (C:\sysType.txt) DO SET arch=%%c

ECHO %arch% | FIND "86" > NUL

IF %ERRORLEVEL% == 0 (

GOTO VISTA

) ELSE (

GOTO 64

)

I also use this and it works fine:

SYSTEMINFO | FIND "OS Name" > C:\osName.txt

FOR /F "usebackq delims=: tokens=2" %%c IN (C:\osName.txt) DO SET vers=%%c

vers always has a proper value. What am I doing wrong?

Posted (edited)

Can we assume the host is Windows-based? How about a registry scan instead?

:OS-check
FOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') DO SET build=%%B
if /I "%build%"=="2600" set OSbuild=XP
if /I "%build%"=="6000" set OSbuild=Vista
if /I "%build%"=="6001" set OSbuild=Vista
if /I "%build%"=="6002" set OSbuild=Vista
if /I "%build%"=="7600" set OSbuild=Win7
if /I "%build%"=="7601" set OSbuild=Win7
if /I "%build%"=="7602" set OSbuild=Win7
FOR /F "tokens=2*" %%A IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') DO SET prodname=%%B
SET ARCH=86
IF EXIST "%SystemRoot%\SysWOW64" set ARCH=64

The 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.html

Scanning systeminfo is kind of clunky when lots of environment variables exist to help you.

%OS%

%PROCESSOR_ARCHITECTURE%

%PROCESSOR_IDENTIFIER%

Edited by Mr_Smartepants
Posted

http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.html

Scanning 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.

Posted

IF EXIST "%SystemRoot%\SysWOW64" set ARCH=64

The 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.

Posted

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.html

http://www.windows-commandline.com/2010/11/system-information-systeminfo-command.html

However 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 7601

You also can use:

C:\>SYSTEMINFO /FO LIST >C:\SysInfo.txt

To read all informations inside the text file and select the one you need to use !

  • 2 years later...
Posted

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!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...