Hello everyone
I have made a similar post to this topic but I did not understand it. I am writing a really big program and it uses settings. So it saves a variable "set var=0" into a bat file and the program would call that bat file and there you go. Bur now I would like to have a more secure way of saving variables... Could some one please give me a quick tutorial on how to...
write a variable to a reg key
read a reg key and store it in a variable
delete a reg key...
For example I would like to save the text "disabled" into a key for a mode in my program and my program could read that key and store it in a variable...
Thank you for all your time
settings using registry
Moderator: DosItHelp
-
- Posts: 126
- Joined: 10 Jun 2011 10:30
Re: settings using registry
I'm not sure you are in the correct forum considering you mentioned that you are writing a "really big program"
But just in case you are actually writing a batch script, I'll point you in the right direction...
Reg.exe is the commandline registry editor so you'll use it to import/export keys into *.reg files.
These files are standard text files and can be written by batch files and parsed by batch files to read/write the registry keys you are wanting to use.
But just in case you are actually writing a batch script, I'll point you in the right direction...
Reg.exe is the commandline registry editor so you'll use it to import/export keys into *.reg files.
These files are standard text files and can be written by batch files and parsed by batch files to read/write the registry keys you are wanting to use.
Re: settings using registry
So could you give me a tutorial , yes it is a bat file (200KB in size)
Re: settings using registry
Adrianvdh wrote:So could you give me a tutorial
Instead, how about you read the help for reg.exe and ask for help on any specific issue that arises.
Re: settings using registry
For using registry :
This page may be for you.
http://technet.microsoft.com/fr-fr/libr ... 10%29.aspx
This page may be for you.
http://technet.microsoft.com/fr-fr/libr ... 10%29.aspx
Re: settings using registry
hehe Is the OP a French native?
Re: settings using registry
OK, here's an example of how to work with the registry. First of all before experimenting make sure you backup the registry key (for my example HKEY_CURRENT_USER\Software) into a .reg file. Otherwise accidentally deleted keys are gone. Also make sure you understand what you're doing!
Regards
aGerman
Code: Select all
@echo off &setlocal
:: good place for your data
set "RegKey=HKCU\Software\MyBatProg"
:: add new data
>nul reg add "%RegKey%" /v "Value1" /t REG_SZ /d "Hello World!" /f
>nul reg add "%RegKey%" /v "Value2" /t REG_SZ /d "123" /f
:: read data and assign a variable
for /f "tokens=2*" %%i in ('reg query "%RegKey%" /v "Value1"') do set "txt=%%j"
echo Text: %txt%
for /f "tokens=2*" %%i in ('reg query "%RegKey%" /v "Value2"') do set "num=%%j"
echo Number: %num%
:: change existing data (same as adding new)
>nul reg add "%RegKey%" /v "Value2" /t REG_SZ /d "1000" /f
:: check
for /f "tokens=2*" %%i in ('reg query "%RegKey%" /v "Value2"') do set "num=%%j"
echo Number: %num%
pause
:: delete a certain value
>nul reg delete "%RegKey%" /v "Value2" /f
:: check (error if the deletion was successful)
reg query "%RegKey%" /v "Value2"
:: delete the entire key
>nul reg delete "%RegKey%" /f
:: check (error if the deletion was successful)
reg query "%RegKey%"
pause
Regards
aGerman
Re: settings using registry
So a "Key" would be like a folder and a "Value" would be like a file?