0

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?

ZygD
  • 2,459
  • 12
  • 26
  • 43

2 Answers2

0

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

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InstallService /v Start /t REG_BINARY /d 4
harrymc
  • 455,459
  • 31
  • 526
  • 924
  • No, like i said i want to edit an existing registry entry, i want to edit the start value. I dont want to add a key. – Surveillance.gov Nov 24 '21 at 11:06
  • 3
    That's then the misunderstanding - you don't need to edit, you just set it. An existing value is just replaced. – harrymc Nov 24 '21 at 11:19
0

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
Ricardo Bohner
  • 3,903
  • 2
  • 18
  • 12
  • thank you, this appears to be working. exactly what i needed, thank you very much. the term /f means run as admin is that correct? i am not familiar with all those commands such as /v /f /t /b etc. Where can i find a documentation on this? Any useful site explaining how this works? Im also woondering about this one '"%~0"' – Surveillance.gov Nov 26 '21 at 09:29
  • /f for "force" otherwise you would get a confirmation request "do you want to substitute the value?". To see all options you could use reg add /? in the command prompt. %~0 means full path of the batch script – Ricardo Bohner Nov 26 '21 at 10:00