?
Solved

reg key XP get ostype

Posted on 2011-05-06
6
Medium Priority
?
473 Views
Last Modified: 2012-05-11
We have a login script, batch file. We need a portion of it executed only if the ostype is XP. Was thinking about something like reading the registry key product name with reg query.

IF something GOTO next ELSE GOTO exit

How can i do this?
0
Comment
Question by:eltel-it-nor
6 Comments
 

Expert Comment

by:xibec
ID: 35704740
with command 'ver'  you see the version of windows
 
0
 

Author Comment

by:eltel-it-nor
ID: 35704750
Ok, thanks. How can i use this in a batch script?
0
 
LVL 4

Expert Comment

by:pritamsh
ID: 35704786
@echo OFF

setlocal ENABLEEXTENSIONS
set KEY_NAME="HKEY_CURRENT_USER\Software\Microsoft\Command Processor"
set VALUE_NAME=DefaultColor

FOR /F "usebackq skip=4 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
    set ValueName=%%A
    set ValueType=%%B
    set ValueValue=%%C
)

if defined ValueName (
    @echo Value Name = %ValueName%
    @echo Value Type = %ValueType%
    @echo Value Value = %ValueValue%
) else (
    @echo %KEY_NAME%\%VALUE_NAME% not found.
)


Kindly refer;

http://stackoverflow.com/questions/445167/how-can-i-get-the-value-of-a-registry-key-from-within-a-batch-script
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:bright12
ID: 35704799
You can try the following code.


set Version=
for /f "skip=1" %%v in ('wmic os get version') do if not defined Version set Version=%%v
for /f "delims=. tokens=1-3" %%a in ("%Version%") do (
  set Version.Major=%%a
  set Version.Minor=%%b
  set Version.Build=%%c
)

set GTR_XP=
if %Version.Major%==5 if %Version.Minor% GTR 1 set GTR_XP=1
if %Version.Major% GTR 5 set GTR_XP=1

if defined GTR_XP (
  ...
)

Open in new window

0
 
LVL 5

Expert Comment

by:xylog
ID: 35705785
reg query "hklm\software\microsoft\windows nt\currentversion" /v productname | findstr /c:"Windows XP"
if errorlevel 1 echo Not XP and goto :EOF
echo XP!!
0
 
LVL 5

Accepted Solution

by:
xylog earned 2000 total points
ID: 35705796
Should be:

reg query "hklm\software\microsoft\windows nt\currentversion" /v productname | findstr /c:"Windows XP"
if errorlevel 1 echo Not XP && goto :EOF
echo XP!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question