How to Change Windows Variable Records

Asked

Viewed 2,806 times

1

It is fact that by programming for Windows, it is possible to store local variables, or in the environment, which in case are saved in windows records.

How do you make change the windows registry variables using the command line if I want to manually clean them to test with my application without these variables already defined?

  • 1

    Use the regedit.exe

  • 1

    Do you say via a certain programming language or directly via the operating system? P.S.: I didn’t understand your edition: what do you mean by "windows registry environment variables"?

  • Via the command line would be ideal, as it is easier to save the command and repeat if necessary, because the tests are repetitive. Actually the issue was confused, I was researching in English read as enviroment and I thought I had written nonsense, but it was right even before the edition.

3 answers

2

You can:

  1. Use the regedit.exe to make the changes
  2. If you want to access via code, you can use the Windows API for this feature;
  3. Alternatively, export the desired Windows registry chunk to a file, edit it, and apply it using regedit.exe /s [NomeArquivoComChavesDoRegistroEditadas].reg;

Complement:

Observing your comment, I believe the third alternative is the most recommended in this case. You can do the following:

  1. Open the regedit.exe, browsing for the registry key you want to "clear";
  2. Export the desired Registry key to a file;
  3. Edit the file in the Notepad, excluding the value lines below the key. Also, include a "-" (minus sign) before the key name. This will indicate that when applying the record, the key should be deleted. It will look like this:

    Windows Registry Editor Version 5.00

    [-HKEY_LOCAL_MACHINE SOFTWARE Mycompaniesproduct]

    "Parametro1"="Value1"

    "Parametro2"="Value2"

  4. Apply the record (double-click on the file you edited) whenever you wish to delete the referred key.

  • 1

    +1 very nice the answer, but I found a way to do it by the command line that in my case as I am repeating the task several times, facilitates.

2


It is possible using native windows application called reg.exe via command line. Reg.exe official documentation.

Examples of use:

Consulting:

REG QUERY HKLM\Software\Microsoft\ResKit /v Version
// Mostra o valor do registro Version

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s
// Mostra todas sub-chaves do valor abaixo do registro Setup

Adding

REG ADD \\ABC\HKLM\Software\MyCo
// Adiciona uma chave HKLM\Software\MyCo na máquina remota ABC

Erasing

REG DELETE HKLM\Software\MyCo\MyApp\Timeout
// Apaga o registro Timeout e todas suas sub-chaves e valores

REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
// Apaga o valor de registro do MTU em MyCo na máquina ZODIAC

0

You can assemble a file .reg also, and run it. For example:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SeuREG\CHAVE]
"valor1"="conteudoValor1"
"valor2"="conteudoValor2"

Save that file teste.reg and just run.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.