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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rafiq01Author Commented:
Excellent!

Works perfectly.

Thanks so much the life saver

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.