修改“可执行文件的路径"一个windows服务 [英] Modifying the "Path to executable" of a windows service

查看:47
本文介绍了修改“可执行文件的路径"一个windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改我的应用程序的路径,但这样做会破坏它,因为该服务仍指向旧位置.

I'd like to modify the path to my application, but doing so breaks it because the service still points to the old location.

转到管理工具>Services 您可以打开一个属性对话框并查看可执行文件的路径,但无法更改它.

By going to Administrative Tools > Services you can open a properties dialog and view the Path to executable, but there is no way to change it.

有没有什么方法可以让用户无需重新安装应用程序就可以修改服务路径?

Is there any way a user can modify the service path without having to reinstall the application ?

推荐答案

还有 SuperUser 上看到的这种方法,它使用了sc 命令行而不是修改注册表:

There is also this approach seen on SuperUser which uses the sc command line instead of modifying the registry:

sc config <service name> binPath= <binary path>

注意:binPath= 后面的空格很重要.您还可以使用以下命令查询当前配置:

Note: the space after binPath= is important. You can also query the current configuration using:

sc qc <service name>

这会显示类似于以下内容的输出:

This displays output similar to:

[SC] QueryServiceConfig 成功

[SC] QueryServiceConfig SUCCESS

SERVICE_NAME:服务名称

SERVICE_NAME: ServiceName

    TYPE               : 10  WIN32_OWN_PROCESS
    START_TYPE         : 2   AUTO_START
    ERROR_CONTROL      : 1   NORMAL
    BINARY_PATH_NAME   : C:\Services\ServiceName
    LOAD_ORDER_GROUP   :
    TAG                : 0
    DISPLAY_NAME       : <Display name>
    DEPENDENCIES       :
    SERVICE_START_NAME : user-name@domain-name

这篇关于修改“可执行文件的路径"一个windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆