0

I wrote a simple Windows service based on this sample. I need to pass a couple of parameters to the service, as command line parameters (reading the Service registry hive does not work on Windows7).
I tried the solution described here but it does not work: when I add the parameters to the value in the <MyService>\ImagePath entry (i.e "D:\MyService.exe" "-param1" "-param2") the service fails to start.
.

Community
  • 1
  • 1
Stefano Piovesan
  • 1,185
  • 3
  • 19
  • 37
  • 1
    I successfully do this with `CreateService` by double quoting the full path of the executable and I'm not quoting the parameters (not sure if that matters or not). Check the escaping in your string (is that backslash and your quotes in your example escaped correctly in the code?). Maybe provide some of your code we can look at... – mark Jun 10 '15 at 14:27
  • I notice that the main function (wmain) in the code you link to doesn't start the service if the first command-line argument begins with a dash or a forward slash. Perhaps that's your problem? – Harry Johnston Jun 10 '15 at 23:02
  • I added a first command-line argument without a dash or a forward slash. The service now starts but no `args` are passed to the main function: `argc` is always 1. – Stefano Piovesan Jun 13 '15 at 05:57

0 Answers0