how to save value of a data in regedit in a variable?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

how to save value of a data in regedit in a variable?

#1 Post by Mohammad_Dos » 25 Aug 2011 09:29

in this key in regedit:
HKLM "SOFTWARE\Eset\ESET Security\CurrentVersion\Info"

there is a data(reg_sz). i want to save value of this data in a variable. how to do that?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: how to save value of a data in regedit in a variable?

#2 Post by aGerman » 25 Aug 2011 13:23

What is the name of the value where you want to save the data (or is it the "no name" default value which exists in each key)?

Regards
aGerman

Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

Re: how to save value of a data in regedit in a variable?

#3 Post by Mohammad_Dos » 25 Aug 2011 14:15

sorry. i forgot...
name of the data is "InstallDir"

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: how to save value of a data in regedit in a variable?

#4 Post by aGerman » 25 Aug 2011 14:20

Try that:

Code: Select all

@echo off &setlocal
for /f "tokens=2*" %%a in ('reg query "HKLM\SOFTWARE\Eset\ESET Security\CurrentVersion\Info" /v "InstallDir"') do set "data=%%b"
echo %data%
pause


Regards
aGerman

Post Reply