bri*_*ary 65
sc.exe config "Service Name" obj= "DOMAIN\User" password= "password" type= own
Run Code Online (Sandbox Code Playgroud)
请参阅为Windows服务设置登录凭据的快捷方式»jonathanmalek.com.
@MattT指出,在Windows Server 2008R2上,您还必须添加type= own.
我只是从powershell调用WMI来执行此操作.
$Svc = Get-WmiObject win32_service -filter "name='ServiceName'"
$Svc.Change($Null, $Null, $Null, $Null, $Null, $Null, "User", "Password")
Run Code Online (Sandbox Code Playgroud)
不要忘记之后重启服务:
Stop-Service -Name 'ServiceName'
Start-Service -Name 'ServiceName'
Run Code Online (Sandbox Code Playgroud)
有关WMI和服务的更多乐趣,请参阅 Win32_Service类
| 归档时间: |
|
| 查看次数: |
58586 次 |
| 最近记录: |