[英]How can I start and stop services on a remote machine?
I have a requirement in the project such that we have to stop a specific service say "x" in a remote machine (which is on the same LAN), change the registry key remotely and start the service again. 我在项目中有一个要求,即我们必须在远程计算机(位于同一LAN上)中停止特定服务“x”,远程更改注册表项并再次启动服务。
I tried the command sc \\server stop service
, but I got the error: 我尝试了
sc \\server stop service
命令,但是我得到了错误:
[SC] GetServiceKeyName FAILED 1060:
[SC] GetServiceKeyName FAILED 1060:
The specified service does not exist as an installed service.
指定的服务不作为已安装的服务存在。
I am using Windows 2003 SP1. 我使用的是Windows 2003 SP1。 Are there any built in commands or APIs that are available on Windows?
Windows上是否有可用的内置命令或API?
I need the commmand to run on the command prompt. 我需要在命令提示符下运行命令。
Also keep in mind that the "service name" argument expected by the "sc" command line tool doesn't always equate to the name you see within the services control panel applet (which is the service "display name"). 还要记住,“sc”命令行工具所期望的“服务名称”参数并不总是等同于您在服务控制面板小程序中看到的名称(即服务“显示名称”)。
For example, the service that as appears "Adobe Acrobat Update Service" in my services control panel applet has an actual name of "AdobeARMservice". 例如,我的服务控制面板小程序中显示为“Adobe Acrobat Update Service”的服务的实际名称为“AdobeARMservice”。 You must use the latter, but not the former, when managing the service through the "sc" utility.
在通过“sc”实用程序管理服务时,您必须使用后者,而不是前者。
Example: 例:
sc Stop "AdobeARMservice" (works)
sc Stop "Adobe Acrobat Update Service" (doesn't work)
To get the "real" name of a service, double-click its entry in the service control panel applet and see the "service name" field on the General tab. 要获取服务的“真实”名称,请在服务控制面板小程序中双击其条目,然后在“常规”选项卡上查看“服务名称”字段。
Of course in some cases, the display name and the service name are the same. 当然,在某些情况下,显示名称和服务名称是相同的。
You may want to look into PSTools from SysInternals . 你可能想看看PSTools从Sysinternals的 。 Those tools are freely available and can help you manage processes on a remote Windows machine.
这些工具是免费提供的,可以帮助您管理远程Windows机器上的进程。
The tools included in the PsTools suite, which are downloadable as a package, are: 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
使用OpenCSManager,然后使用OpenService,然后使用StartService。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.