0

Can I set a service to run in its own container thru Powershell? ie.

What is the Powershell equivalent of sc config <service name> type= own

Ayan Mullick
  • 67
  • 2
  • 11
  • 38
  • 1
    What's wrong with using `sc`? – vonPryz Jan 08 '14 at 12:41
  • Pipe-lining becomes difficult. Once I identify an svchost hogging resources I want to put all the services in it in their separate containers and restart them, remotely thru Powershell-remoting, to identify the culprit service. – Ayan Mullick Jan 08 '14 at 12:46

1 Answers1

2

You can change service type property on the corresponding WMI object.

# get service
$s = (Get-WmiObject win32_service -filter "Name='Fax'")

# change service type
$s.Change($null, $null, 16) # 16 = "Own Process"

Other values you can find here (http://msdn.microsoft.com/en-us/library/aa384901(v=vs.85).aspx)

Make sure that ReturnValue from change method is equal to 0. Meaning of error codes you can find in the link above.