I wrote a service program with WinAPI functions with c++ And I want to create that by wmic.exe in service manager with bellow command :

service create name="test" where path = "C:\Users\msi\Desktop\SampleService.exe"

But it give me the error :

Invalid format.
Hint: <assignlist> = <propertyname>=<propertyvalue> [, <assignlist>].

How can i create a service with wmic.exe tool?

  • why not use sc.exe from normal commandline? is wmic requirement? – Drako Nov 13 '18 at 9:09
  • @Drako I know sc.exe but i have to use of wmic. – BattleTested Nov 13 '18 at 9:10
  • The error message means that you shouldn't use where and should write it like service create name="test", path="xxx" but this doesn't work either. As far as I can see, wmic cannot create a system service. – harrymc Nov 18 '18 at 13:10

I believe the answer is that wmic cannot create a new system service.

I have run an elevated Command Prompt and executed the command wmic service create /?:Full, to receive this output:

enter image description here

The list of properties has included every possible argument that a system service would require, all marked as "N/A", meaning "Not Applicable".

I have also searched on google for "wmic service create", and found a paltry four answers, but none of them was related to creating a service.

I think that you will need to resort to another tool than wmic.

For example, PowerShell documentation includes the applet New-Service.

WMI itself includes such a method in Create method of the Win32_Service class, but you will need to call it via other method than wmic.

  • Thanks. but what is the application of create in wmic for service ? – BattleTested Nov 19 '18 at 5:23
  • 1
    create is a legal keyword and works for other verbs like process but not for service. Seems like this combination of keywords was just never implemented, by intention or by omission, so it only generates a non-informative error message. When I try it with a correct syntax, I get the message "ERROR: Description = Unsupported parameter", which I think means that "service create" is unsupported. – harrymc Nov 19 '18 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.