How to add 'Parameters' key, it's value name and value value in the registry using sc.exe

Hello,
In order to start an application with a service when the computer starts I am have created a service using the following code:

sc create MyTestService binPath= c:\windows\system32\srvany.exe type= own type= interact start= auto

This works perfectly to create the service with start type automatic and interact with desktop. However, I need to add a key called 'Parameters' in the registry created by the above command under:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyTestService]

And, then I want to add a value like:

"Application"="c:\\Program Files\\3D\\MyTestService"

After creating the service with the sc.exe I can manually create this 'Parameter' key, add value and it wroks fine but I do not want to do this manually. I want to do it through sc.exe.

Your quick response is greatly appreciated.

sc create MyTestService binPath= c:\windows\system32\srvany.exe type= own type= interact start= auto

Open in new window

rafiq01Asked:
Who is Participating?
 
oBdACommented:
That can't be done with sc.exe, you'll need an additional command after that.

reg.exe add "HKLM\SYSTEM\CurrentControlSet\Services\MyTestService\Parameters" /v "Application" /d "C:\Program Files\3D\MyTestApp.exe" /f

Open in new window

0
 
rafiq01Author Commented:
Correction:
I want to create a key called 'Parameters' under:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyTestService]

And, then I want to add a value like:

"Application"="c:\\Program Files\\3D\\MyTestApp.exe"
0
 
rafiq01Author Commented:
Excellent!

Works perfectly.

Thanks so much the life saver

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.