Windows service installed with Procrun works in //TS mode, but doesn't start as a Windows service saying it "started and then stopped"

Don't use any white-space in the service name!

After many hours of testing and pulling apart Tomcat and duplicating it's bootstrap process, the fix for my problem ended up being that Apache Commons Daemon (Procrun) does not work properly when there is white-space in the name of the Windows service.

It seemingly correctly installs and registers a service with Windows when there are spaces in the service name. The Windows registry entries even look correct. The service even runs in debug (aka TS or console) mode just fine. When run, however, as an actual service launched by Windows it fails if the service was installed with a white-space in the service name.

I sure wish Procrun had some type of log output when it fails! Good logging can make debugging issues like this a snap.

I did need to have multiple words in my service name, so I named my service with one word and changed the name with the "DisplayName" parameter:

> prunsrv.exe //IS//MyService --Install="C:\path-to-prunsrv.exe" --Jvm=auto \
  --Startup=auto --StartMode=jvm --Classpath="C:\path-to-MyService.jar" \
  --StartClass=com.mydomain.MyService --DisplayName="My Service"

I wanted to give some additional information about what '11101101b' said above. (This is my first post, so please be gentle!)

I was able to get the service to install correctly with spaces in the service name by changing the //IS//MyService part of his command to instead be the following, which I suspect is what he also did. (I apologize if I'm assuming incorrectly.) Notice that the opening double quote is at the beginning of the string rather than at the beginning of the service name.

"//IS//My Service"

As was the case for him, the service installed correctly and looked correct, but it wouldn't start. I was able to get around that by changing the service's ImagePath value data setting in the registry to have the same change for the //RS//My Service part of the command. Therefore, the registry value instead had the following in its data setting:

"//RS//My Service"

Everything seems to be working without any problems.