Put a registry key in variable and split it up!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
camerlengo
Posts: 4
Joined: 12 Jan 2018 11:31
Contact:

Put a registry key in variable and split it up!

#1 Post by camerlengo » 12 Jan 2018 11:38

Hello everyone,

since I need to install a powerpoint add-in without prompting messages I need to create a batch file to realise it.

First of all, my problem is that I don't know the commands to do what's in my mind. I hope you can help me out!

Problem:
I want to get the value of a registry key and put in into a variable first. I don't know how to get the final output into my variable.
When i put in 'reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer"' for which the output is

(Standard) REG_SZ Word.Application.15 (those must be all parts of the key)

I want to save the "15" in a variable and after that concatenate it with two other strings (a wrap around) to combine all of those to a registry path file which i want to use.

However i dont know how to realise this, hopefully you can help me!

Kind regards

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Put a registry key in variable and split it up!

#2 Post by Squashman » 12 Jan 2018 15:18

Code: Select all

for /F "skip=1 tokens=3 delims=." %%G IN ('reg query "HKEY_CLASSES_ROOT\Word.Application\CurVer" /ve') do set ver=%%G

camerlengo
Posts: 4
Joined: 12 Jan 2018 11:31
Contact:

Re: Put a registry key in variable and split it up!

#3 Post by camerlengo » 13 Jan 2018 04:12

Thanks Squashman! But what is my variable name then? and how can i concatenate it with two other strings?

camerlengo
Posts: 4
Joined: 12 Jan 2018 11:31
Contact:

Re: Put a registry key in variable and split it up!

#4 Post by camerlengo » 13 Jan 2018 04:20

Is that code correct?

Code: Select all

for /F "skip=1 tokens=3 delims=." %%G IN ('reg query "HKEY_CLASSES_ROOT\PowerPoint.Application\CurVer" /ve') do set ver=%%G

SET a="HKEY_CURRENT_USER\Software\Microsoft\Office\"
SET b=".0\PowerPoint\AddIns\MyAddIn"
SET path=%a%%%G%b%

REG ADD %path% /v "AutoLoad" /t REG_DWORD /d 1 /f
REG ADD %path% /v "Path" /t REG_SZ /d AddIn.ppam /f
I want to create two keys in the registry to make powerpoint automatically load my add in. To keep the code dynamic i want to get the powerpoint version and afterwards concatenate it with the variables a and b which i wrap around to create a string that contains the registry path.
Last edited by aGerman on 13 Jan 2018 05:51, edited 1 time in total.
Reason: code formatting

camerlengo
Posts: 4
Joined: 12 Jan 2018 11:31
Contact:

Re: Put a registry key in variable and split it up!

#5 Post by camerlengo » 14 Jan 2018 05:23

I still couldn't figure it out. It also says that the "reg" command is invalid

Post Reply