繁体   English   中英

如何在远程计算机上启动和停止服务?

[英]How can I start and stop services on a remote machine?

我在项目中有一个要求,即我们必须在远程计算机(位于同一LAN上)中停止特定服务“x”,远程更改注册表项并再次启动服务。

我尝试了sc \\server stop service命令,但是我得到了错误:

[SC] GetServiceKeyName FAILED 1060:

指定的服务不作为已安装的服务存在。

我使用的是Windows 2003 SP1。 Windows上是否有可用的内置命令或API?

我需要在命令提示符下运行命令。

还要记住,“sc”命令行工具所期望的“服务名称”参数并不总是等同于您在服务控制面板小程序中看到的名称(即服务“显示名称”)。

例如,我的服务控制面板小程序中显示为“Adobe Acrobat Update Service”的服务的实际名称为“AdobeARMservice”。 在通过“sc”实用程序管理服务时,您必须使用后者,而不是前者。

例:

sc Stop "AdobeARMservice" (works)
sc Stop "Adobe Acrobat Update Service" (doesn't work)

要获取服务的“真实”名称,请在服务控制面板小程序中双击其条目,然后在“常规”选项卡上查看“服务名称”字段。

当然,在某些情况下,显示名称和服务名称是相同的。

你可能想看看PSToolsSysinternals的 这些工具是免费提供的,可以帮助您管理远程Windows机器上的进程。

PsTools套件中包含的工具可以作为包下载,它们是:

PsExec - execute processes remotely
PsFile - shows files opened remotely
PsGetSid - display the SID of a computer or a user
PsInfo - list information about a system
PsKill - kill processes by name or process ID
PsList - list detailed information about processes
PsLoggedOn - see who's logged on locally and via resource sharing 
PsLogList - dump event log records
PsPasswd - changes account passwords
PsService - view and control services
PsShutdown - shuts down and optionally reboots a computer
PsSuspend - suspends processes
PsUptime - shows you how long a system has been running since its last reboot

从这个URL

To stop a service remotely you can use the command sc.

Example:
> sc \\computer stop "Service Name"
> sc \\computer start "Service Name"

也许你错过了一个“\\”字符?

使用OpenCSManager,然后使用OpenService,然后使用StartService。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM