Skip to main content

How to add a service which executable file has a space and requires parameters? [Resolved]

I would like a python script as a Windows service, using sc. The problem is that the path to the executable has a space and requires parameters.

Therefore

sc create DNSResolver127 binPath= '"C:\Program Files (x86)\Python36-32\python.exe" D:/32dsdnsproxy/32dsdnsproxy.py'

fails (I tried to enclose the whole option in single quotes)

How to add such a service?


Question Credit: WoJ
Question Reference
Asked July 13, 2019
Posted Under: Network
31 views
1 Answers

You have to escape the quote marks like this:

sc create MyService binpath= "\"C:\Program Files (x86)\Python36-32\python.exe\" D:/32dsdnsproxy/32dsdnsproxy.py"

... but keep in mind that this will only work if 32dsdnsproxy.py is designed to run as a service, otherwise you'll need to use a tool such as nssm or Apache Daemon's procrun to launch your application as a service.


credit: Harry Johnston
Answered July 13, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA