如何从命令行更改 Windows 服务的用户凭据?

如何从命令行更改 Windows 服务的用户凭据?

如何从命令行更改 Windows 服务的用户凭据?

答案1

您正在寻找:

sc config <servicename> obj= <accountname> password= <password>

“sc”命令也适用于远程机器。启动时不带任何参数即可获取更多信息。(它要求在许多参数后加空格,这有点奇怪。我还没见过类似的命令行程序。)

答案2

您也可以使用 passgen.exe,它非常方便,可以为您生成复杂的密码并设置它。

C:\>passgen.exe /?


===============================================================================
passgen.exe v. 1.1, Copyright (c) 2005, Jesper M. Johansson.
This program is used to generate and/or set a password on an arbitrary account.
For complete details on how to use passgen.exe see the doc file that is
distributed with the tool.

This program is primarily distributed with the
"Protecting Your Windows Network" book. For feedback on the tool
e-mail [email protected].
passgen.exe may be freely re-distributed within the organization that paid for the book so long as it remains unmodified and is accompanied by the readme file.

===============================================================================

There are three valid modes and associated options you may use:

passgen.exe -g <identifier> <pass phrase> [-l <desired length>]
        [-e <desired character set>] [-c <account name> [<old password>]]
        [-m <machine/domain>] [-d <service name>] [-h]

passgen.exe -r [-l <desired length>] [-e <desired character set>]
        [-c <account name> [<old password>]] [-m <machine/domain>]
        [-d <service name>] [-h]

passgen.exe -s [-c <account name> [<old password>] [-m <machine/domain>]
        [-d <service name>]]

For details on the usage of these options see the readme file that comes with
the tool. If you received the tool without a readme file please e-mail
[email protected]

===============================================================================

相关内容