Answered by:
Powershell equivalent of sc.exe config winmgmt type= own

Question
-
Is there a PowerShell command that is equivalent that I can use to create a service in it's own process such as 'sc.exe config winmgmt type= own'? Every so often I come upon a machine in my domain where wingmgt service as stopped and I can't get it started until I run the service control program. I want to use PowerShell but was hoping the equivalent command existed.
Monday, April 2, 2018 4:40 PM
Answers
-
I take that back. It appears that you can use WMI to change the service type:
https://msdn.microsoft.com/en-us/library/aa384901(v=vs.85).aspx
\_(ツ)_/
- Marked as answer by greatestcommonfactor Monday, April 2, 2018 5:12 PM
Monday, April 2, 2018 4:51 PM
All replies
-
That command works in PowerShell. There is no PS command that changes a service type.
\_(ツ)_/
Monday, April 2, 2018 4:47 PM -
I take that back. It appears that you can use WMI to change the service type:
https://msdn.microsoft.com/en-us/library/aa384901(v=vs.85).aspx
\_(ツ)_/
- Marked as answer by greatestcommonfactor Monday, April 2, 2018 5:12 PM
Monday, April 2, 2018 4:51 PM -
That was perfect. Thank you.
$s = (Get-WmiObject win32_service -filter "Name='winmgmt'")
$s.Change($null, $null, 16)
Monday, April 2, 2018 5:12 PM -
you can set ServiceType property as well using WMI
Regards kvprasoon
Monday, April 2, 2018 5:18 PM -
you can set ServiceType property as well using WMI
Regards kvprasoon
Yup. That is what we said. Look up.\_(ツ)_/
Monday, April 2, 2018 5:20 PM -
you can set ServiceType property as well using WMI
Regards kvprasoon
Yup. That is what we said. Look up.
\_(ツ)_/
I was pointing to $s.Change($null,$null, 16) this expressionRegards kvprasoon
Monday, April 2, 2018 6:03 PM -
You cannot change "ServiceType" it is a readonly property. It can only be set with the "Change" method.
\_(ツ)_/
Monday, April 2, 2018 6:08 PM -
You cannot change "ServiceType" it is a readonly property. It can only be set with the "Change" method.
\_(ツ)_/
I Still didn't try this. But the Get-Member shows below.
Regards kvprasoon
Monday, April 2, 2018 7:08 PM -
That may be but the docs say:
ServiceTypeData type: string
Access type: Read-only
Qualifiers: MappingStrings ("Win32API|Service Structures|QUERY_SERVICE_CONFIG|dwServiceType"),
DisplayName ("Service Type") Type of service provided to calling processes. The values are: Kernel Driver ("Kernel Driver") File System Driver ("File System Driver") Adapter ("Adapter") Recognizer Driver ("Recognizer Driver") Own Process ("Own Process") Share Process ("Share Process") Interactive Process ("Interactive Process")
\_(ツ)_/
- Edited by jrv Monday, April 2, 2018 7:14 PM
Monday, April 2, 2018 7:13 PM -
I tested the "Put" and it does work on W10 and later.
\_(ツ)_/
Monday, April 2, 2018 7:17 PM -
Works on Windows 7 and later. WS2003/xp it appears to be readonly.
\_(ツ)_/
Monday, April 2, 2018 7:23 PM