Friday, October 3, 2014

sc.exe syntax trick

For the first time in 10 years I had to create a Windows Service manually. This was caused by an issue described in my previous post The installer was interrupted. I look at the sc.exe command documentation and start typing at the DOS prompt. Everything I try doesn't work and all I get back is the help text. I'm puzzled why something like this command doesn't work:

sc create FooService binPath="C:\blah\foo.exe" start=auto

After staring and squinting at the documentation for some time I eventually notice that the documentation has a space after the = sign on the options. I have never seen a command in any platform on any operating system (including Windows) in the last 30 years that used a syntax like this:

option= SomeValue

(note the space) But it's true! Putting a space after the = signs in my create command makes it work. As the self-described criminal genius Vizzini said, "Inconceivable!".

No comments:

Post a Comment