Jump to content


Photo

Batch file issues set command


  • Please log in to reply
4 replies to this topic

#1 thedexmonster

thedexmonster

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts
  • Location:California
  • OS:Windows 7 x64

Posted 21 December 2011 - 02:54 AM

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?

#2 Mr_Smartepants

Mr_Smartepants

    DriverPacks.net Administrator

  • Members
  • PipPipPipPipPipPip
  • 797 posts
  • Location:Cambridgeshire
  • OS:Windows 7

Posted 21 December 2011 - 06:25 AM

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-c...om-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, 21 December 2011 - 06:31 AM.


#3 thedexmonster

thedexmonster

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts
  • Location:California
  • OS:Windows 7 x64

Posted 22 December 2011 - 05:06 AM

http://www.windows-c...om-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.

#4 thedexmonster

thedexmonster

    Advanced Member

  • Members
  • PipPipPip
  • 67 posts
  • Location:California
  • OS:Windows 7 x64

Posted 22 December 2011 - 05:16 AM

IF EXIST "%SystemRoot%\SysWOW64" set ARCH=64[/code]
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.

#5 myselfidem

myselfidem

    Wincert Addict

  • Members
  • PipPipPipPipPipPip
  • 588 posts
  • Location:Suisse
  • OS:Windows 7

Posted 26 December 2011 - 06:16 PM

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-c...om-command.html

http://www.windows-c...fo-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 !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users