Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmd: regedit from cmd

how can i run to a specify path in regedit from cmd? I would like to add a new key to a specific service. Can someone help me? I would like to do this from a c# code, but first i am trying to do it from cmd. Thx

i would like to navigate from cmd to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Service and add in the Service service a new key with a value. i did write in cmd: regedit "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Service" add /v KeyName Parameters but i have an error saying that it can't load the file. why?

like image 236
elisa Avatar asked Mar 30 '11 14:03

elisa


2 Answers

you can use

reg add "HKLM\SYSTEM\CurrentControlSet\services\Service" /v "KeyName" /d "Parameters" /f

Which would create a value (/v) named KeyName with data containing Parameters. the /f switch is used to override any confirmations and interruptions so the command can be executed without user input,omit for testing. additionaly,you can replace /v with /ve (value empty) and not specify a value name at all. this allows writting data (/d) to the default key value. also,if the path you intent to write to doesn't exist,the keys will be created without any warning.

for more information type reg /? in the command line

like image 81
EstimatedTime14y Avatar answered Oct 27 '22 11:10

EstimatedTime14y


To add a Registry Entry from cmd using regedit, create a *.reg file containing the data you want to add. Simple example:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\TestKey]
"TestDWORD"=dword:00000123

and then execute this: regedit /s myreg.reg

This adds a Key (displayed like a folder in the regedit browser) named TestKey to HKEY_CURRENT_USER\Software. The TestKey Key contains a DWORD entry named "TestDWORD" that contains 123 in hex (291 in decimal)


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\TestKey]
"TestDWORD"=dword:00000123

[HKEY_CURRENT_USER\Software\TestKey\SubKey]
"StringEntry"="StringValue"

This creates TestKey @ HKEY_CURRENT_USER\Software plus a sub-key "SubKey" of TestKey with a String Entry (named "StringEntry") and value of "StringValue"

There's a simple way to find out how to create different kinds of entries: Use the regedit gui to create the desired entries, then mark the key and use the Menu File -> Export. The generated file will contain the key(s) and it's entries.


To create a Registry Entry in C#: http://msdn.microsoft.com/en-us/library/h5e7chcf.aspx

like image 41
BatteryBackupUnit Avatar answered Oct 27 '22 11:10

BatteryBackupUnit