Czy możliwa jest modyfikacja wpisu do rejestru poprzez.bat/.skrypt cmd?

Czy można modyfikować wartość rejestru (string lub DWORD) poprzez a .bat/skrypt cmd?

Author: Ross Ridge, 2008-09-25

8 answers

Możesz użyć polecenia REG. Od http://www.ss64.com/nt/reg.html :

Syntax:

   REG QUERY [ROOT\]RegKey /v ValueName [/s]
   REG QUERY [ROOT\]RegKey /ve  --This returns the (default) value

   REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f]
   REG ADD [ROOT\]RegKey /ve [/d Data] [/f]  -- Set the (default) value

   REG DELETE [ROOT\]RegKey /v ValueName [/f]
   REG DELETE [ROOT\]RegKey /ve [/f]  -- Remove the (default) value
   REG DELETE [ROOT\]RegKey /va [/f]  -- Delete all values under this key

   REG COPY  [\\SourceMachine\][ROOT\]RegKey [\\DestMachine\][ROOT\]RegKey

   REG EXPORT [ROOT\]RegKey FileName.reg
   REG IMPORT FileName.reg
   REG SAVE [ROOT\]RegKey FileName.hiv
   REG RESTORE \\MachineName\[ROOT]\KeyName FileName.hiv

   REG LOAD FileName KeyName
   REG UNLOAD KeyName

   REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s]
   REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s]

Key:
   ROOT :
         HKLM = HKey_Local_machine (default)
         HKCU = HKey_current_user
         HKU  = HKey_users
         HKCR = HKey_classes_root

   ValueName : The value, under the selected RegKey, to edit.
               (default is all keys and values)

   /d Data   : The actual data to store as a "String", integer etc

   /f        : Force an update without prompting "Value exists, overwrite Y/N"

   \\Machine : Name of remote machine - omitting defaults to current machine.
                Only HKLM and HKU are available on remote machines.

   FileName  : The filename to save or restore a registry hive.

   KeyName   : A key name to load a hive file into. (Creating a new key)

   /S        : Query all subkeys and values.

   /S Separator : Character to use as the separator in REG_MULTI_SZ values
                  the default is "\0" 

   /t DataType  : REG_SZ (default) | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ

   Output    : /od (only differences) /os (only matches) /oa (all) /on (no output)
 39
Author: Rui Vieira,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-02-25 18:49:27

@ Franci Penov-modify is possible in the sense of overwrite with /f, eg

reg add "HKCU\Software\etc\etc" /f /v "value" /t REG_SZ /d "Yes"
 94
Author: nray,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-01-15 03:58:40

Tak, możesz skryptować używając polecenia reg. Przykład:

reg add HKCU\Software\SomeProduct
reg add HKCU\Software\SomeProduct /v Version /t REG_SZ /d v2.4.6

Spowoduje to utworzenie klucza HKEY_CURRENT_USER\Software\SomeProduct i dodanie do tego klucza wartości "v2.4.6" o nazwie "Version".

reg /? mA szczegóły.

 25
Author: Factor Mystic,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-24 21:54:50

W ten sposób możesz modyfikować rejestr, bez monitu tak lub nie i nie zapomnij uruchomić jako administrator

reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\etc\etc   /v Valuename /t REG_SZ /d valuedata  /f 

Poniżej znajduje się prawdziwy przykład, aby ustawić internet explorer jako domyślną przeglądarkę

reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice   /v ProgId /t REG_SZ /d IE.HTTPS  /f 

/F Force: Wymuś aktualizację bez monitu " wartość istnieje, zastąp Y/N "

/D Data: rzeczywiste dane do zapisania jako "String", integer itp

/V Wartość: Nazwa wartości np. ProgId

/ T DataType: REG_SZ (domyślnie) / REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ

Dowiedz się więcej o odczytywaniu, ustawianiu lub usuwaniu kluczy rejestru i wartości, zapisywaniu i przywracaniu z .Plik REG. from here

 7
Author: Shersha Fn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-29 15:57:55

Możesz zrobić/ align = "left" / Możesz wyeksportować dowolną część rejestru jako .plik reg, aby zobaczyć, jaki jest format.

Format tutaj:

Http://support.microsoft.com/kb/310516

Można go uruchomić na dowolnym komputerze z systemem Windows bez instalowania innego oprogramowania.

 4
Author: Lou Franco,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-24 21:54:32

Tak. Możesz użyć reg.exe, który pochodzi z systemu operacyjnego, aby dodać, usunąć lub zapytanie wartości rejestru. Reg.exe nie ma jawnego polecenia Modyfikuj, ale możesz to zrobić, wykonując delete, a następnie add.

 1
Author: Franci Penov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-24 21:56:03

Oprócz reg.exe, Gorąco polecam również sprawdzić powershell, jego znacznie bardziej zdolny w obsłudze rejestru.

 1
Author: Tim Jarvis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-24 22:23:39
 -1
Author: schaelle,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2008-09-24 21:54:20