Solved Batch File To Set Registry Values As Variables

September 17, 2014 at 19:03:27
Specs: Windows 7
I am trying to find a way to store a registry key value in a variable to use it later.

For example: some data in a value is a full path to an executable file that I want to delete from my hard disk. So if I can store it as a variable I can use it on a DEL command and delete it.

Seems REG QUERY can do it in some way, but it returns too much trash. Here's another example.

If I use

REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v AlcoholAutomount

It returns to me

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
AlcoholAutomount REG_SZ "C:\Program Files (x86)\Alcohol Soft\Alcohol 120\AxAutoMntSrv.exe"

I just want the part "C:\Program Files (x86)\Alcohol Soft\Alcohol 120\AxAutoMntSrv.exe", which is the data of the AlcoholAutomount value.

Any clues?


See More: Batch File To Set Registry Values As Variables

Report •


✔ Best Answer
September 18, 2014 at 04:52:01
So does that meet your need?

=====================
M2 Golden-Triangle



#1
September 18, 2014 at 00:43:21
Not clear what this site may have done to your reg out. Do you get a line like this:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\AlcoholAutomount REG_SZ "C:\Program Files (x86)\Alcohol Soft\Alcohol 120\AxAutoMntSrv.exe"

=====================
M2 Golden-Triangle


Report •

#2
September 18, 2014 at 04:04:29
Not exactly. I'll comment the resulting query.

<blank line>
<next line>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
<next line>AlcoholAutomount REG_SZ "C:\Program Files (x86)\Alcohol Soft\Alcohol 120\AxAutoMntSrv.exe"

Where:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run (is the queued tree, in one line)

AlcoholAutomount (is the value, in another line, followed and preceded by spaces)

REG_SZ (is the data type, followed and preceded by spaces)

"C:\Program Files (x86)\Alcohol Soft\Alcohol 120\AxAutoMntSrv.exe" (is the data of AlcoholAutomount value, preceded by spaces)

message edited by mrdamm


Report •

#3
September 18, 2014 at 04:15:39
By the way, I've managed a way to catch it trying hundreds of times. the result is as follows:

FOR /f "skip=2 tokens=5*" %%a In ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "AlcoholAutomount"') do SET arqvirus=%%a
echo "%arqvirus%"


Report •

Related Solutions

#4
September 18, 2014 at 04:52:01
✔ Best Answer
So does that meet your need?

=====================
M2 Golden-Triangle


Report •

#5
September 18, 2014 at 05:09:40
Yes, completely. Thanks for the answers.

Report •


Ask Question