How to change user credentials of windows service from command line?

前端 未结 4 628
执笔经年
执笔经年 2020-12-08 10:00

How to change user credentials of windows service from command line?

4条回答
  •  广开言路
    2020-12-08 10:14

    I simply called WMI from powershell to do this.

    $Svc = Get-WmiObject win32_service -filter "name='ServiceName'"
    $Svc.Change($Null, $Null, $Null, $Null, $Null, $Null, "User", "Password")
    

    Don't forget to restart the service afterwards:

    Stop-Service -Name 'ServiceName'
    Start-Service -Name 'ServiceName'
    

    For more fun with WMI and services, see Win32_Service Class

提交回复
热议问题