samiam41
asked on
Convert exe to service
Hey Experts. I have a program (in-house app) that needs to run continuously so I decided I would take the exe and make it into a service. When I run the command, I get the message [SC] CreateService Success but when I try to launch the service, it errors out with the standard "Could not start the program service on local computer / error 1053".
Here is the command I am using:
Not sure what I'm missing here but it would be great to get this working. I'm running this when the process is not already running, logged in with local admin rights and this is a Windows 2003 server. Thanks for your help!
Here is the command I am using:
sc create Program binPath= "c:\program name.exe" DisplayName= "Chat Program" start= auto
Not sure what I'm missing here but it would be great to get this working. I'm running this when the process is not already running, logged in with local admin rights and this is a Windows 2003 server. Thanks for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried each suggestion you made in your reply and each yielded the same error (could not start service.....)
After creating the service, do I need to restart the server? I didn't think so.
After creating the service, do I need to restart the server? I didn't think so.
ASKER
Ok. I tried the NSSM again but did so after making a couple of changes. First, the exe has a space between the name [Chat Program.exe]. So I made a copy of the program and renamed it ChatProgram.exe. Then I created it again using NSSM, after making sure all references to that service were deleted out, with a different service name than was used previous. Lastly, I didn't use the [browse] option when NSSM opened up. I simply typed in the path of the exe. I noticed when I would use the browse option, the path I selected wasn't displayed but actually showed the exe of the NSSM path!
Whatever it was worked as the service runs like it should. Any suggestions on what could have been the issue? Was the space in the exe causing a problem? Thanks for your help. I'll award points once I hear back.
Whatever it was worked as the service runs like it should. Any suggestions on what could have been the issue? Was the space in the exe causing a problem? Thanks for your help. I'll award points once I hear back.
Sorry, I have no idea what went wrong the first time. Might have been leftovers from the sc.exe attempts.
Just checked with the current version of nssm; I put nssm.exe and a batch file named "Batch Service.cmd" (including the space) into the same folder, ran nssm.exe install "Batch Service" from an elevated command prompt, used the Browse button to find the batch file, and started the service. The batch file is happily writing its time stamps.
Just checked with the current version of nssm; I put nssm.exe and a batch file named "Batch Service.cmd" (including the space) into the same folder, ran nssm.exe install "Batch Service" from an elevated command prompt, used the Browse button to find the batch file, and started the service. The batch file is happily writing its time stamps.
@echo off
setlocal
set LogFile=%~dpn0.log
:Loop
>"%LogFile%" echo %Date% %Time% ---- %*
sleep.exe 60
goto Loop
ASKER
Thanks as always for your time and attention to this question!
ASKER