Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

I don't know what "run to a specify path in regedit from cmd" means.

However, if you want set a registry key from a batch file, just create a .reg file by exporting it from Regedit, then run reg import [filename.reg] (where [filename.reg] is the name of the file you exported).

If you want to open up Regedit to show a certain key, see How to launch Windows' RegEdit with certain path?.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top