Modifying the “Path to executable” of a windows service

后端 未结 8 1504
终归单人心
终归单人心 2020-11-30 17:11

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

By going to Administrative Tools

相关标签:
8条回答
  • 2020-11-30 18:02

    A little bit deeper with 'SC' command, we are able to extract all 'Services Name' and got all 'QueryServiceConfig' :)

    >SC QUERY > "%computername%-services.txt" [enter]
    
    >FIND "SERVICE_NAME: " "%computername%-services.txt" /i > "%computername%-services-name.txt" [enter]
    
    >NOTEPAD2 "%computername%-services-name.txt" [enter]
    

    Do 'small' NOTEPAD2 editing..

    Then, continue with 'CMD'..

    >FOR /F "DELIMS= SKIP=2" %S IN ('TYPE "%computername%-services-name.txt"') DO @SC QC "%S" >> "%computername%-services-list-config.txt" [enter]
    
    >NOTEPAD2 "%computername%-services-list-config.txt" [enter]
    

    Raw data is ready for feeding 'future batch file' so the result is look like this below!!!

    + -------------+-------------------------+---------------------------+---------------+--------------------------------------------------+------------------+-----+----------------+--------------+--------------------+
    | SERVICE_NAME | TYPE                    | START_TYPE                | ERROR_CONTROL | BINARY_PATH_NAME                                 | LOAD_ORDER_GROUP | TAG | DISPLAY_NAME   | DEPENDENCIES | SERVICE_START_NAME |
    + -------------+-------------------------+---------------------------+---------------+--------------------------------------------------+------------------+-----+----------------+--------------+--------------------+
    + WSearch      | 10  WIN32_OWN_PROCESS   | 2   AUTO_START  (DELAYED) | 1   NORMAL    | C:\Windows\system32\SearchIndexer.exe /Embedding | none             | 0   | Windows Search | RPCSS        | LocalSystem        |
    + wuauserv     | 20  WIN32_SHARE_PROCESS | 2   AUTO_START  (DELAYED) | 1   NORMAL    | C:\Windows\system32\svchost.exe -k netsvcs       | none             | 0   | Windows Update | rpcss        | LocalSystem        |
    

    But, HTML will be pretty easier :D

    Any bright ideas for improvement are welcome V^_^

    0 讨论(0)
  • 2020-11-30 18:06

    You can delete the service:

    sc delete ServiceName
    

    Then recreate the service.

    0 讨论(0)
提交回复
热议问题