Thursday, August 20, 2015

How to create a service with WMIC?



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: = = [, ].



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


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...