Modifying the “Path to executable” of a windows service

后端 未结 8 1502
终归单人心
终归单人心 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 17:46

    Slight modification to this @CodeMaker 's answer, for anyone like me who is trying to modify a MongoDB service to use authentication.

    When I looked at the "Path to executable" in "Services" the executed line already contained speech marks. So I had to make minor modification to his example.

    To be specific.

    1. Type Services in Windows
    2. Find MongoDB (or the service you want to change) and open the service, making sure to stop it.
    3. Make a note of the Service Name (not the display name)
    4. Look up and copy the "Path to executable" and copy it.

    For me the path was (note the speech marks)

    "C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe" --config "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg" --service
    

    In a command line type

    sc config MongoDB binPath= ""
    

    In my case this was

    sc config MongoDB binPath= "\"C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe\" --config \"C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg\" --service -- auth"
    

提交回复
热议问题