How to edit registry with cmd? [duplicate]

I want to edit the start type from a service with command prompt.

For example delivery-optimisation-service :

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InstallService\DoSvc

My goal is to create a bat file that will allow me to set the start value from the service.

Value 4 for disabled and value 3 for manually.

I guess the command must look similar to this:

reg edit HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InstallService\DoSvc \Start \value_4

Obviously this command is wrong, anyone please let me know what the correct command is?

2

2 Answers

There is no reg edit command, you should use the documentedreg add:

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InstallService /v Start /t REG_BINARY /d 4
2

To set the value to 4 try this code. The net session part makes sure the batch runs as admin since you need admin rights to change the value. Also you would have to use the /f switch so the command doesn't ask for confirmation if you want so override the existing value.

@echo off
net session >nul 2>&1 || (powershell start -verb runas '"%~0"' &exit /b)
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DoSvc" /v Start /t reg_dword /d 4 /f
2

You Might Also Like