Sign in to follow this  
Followers 0
Trax

Problems running a compiled script as a service

8 posts in this topic

   I am running a compiled script as a service and have encountered a problem. For reference I am using a shell called exe2service. The basics of the script are simple. It communicates to a scale via RS232 (com port) and continually logs the findings.

   When the computer boots the service starts as suspected even before logging in. I can tell because the TX and RX lights on the scale flicker continually and when I do log in the log that the program generates is date and time stamped correctly.

   Now the problem.... when someone logs off the service hangs or something. The TX and RX lights no longer flicker and the log that is generated no longer gets updated. The service still shows up in the SCM as being started but nothing is happening. To get the service going again I have to restart it.

   I have gone as far as putting a beep() in the main loop and it beeps until I log off at which point the mail loop no longer appears running. I am at a loss. Something about logging off. Any ideas on how to debug this?

 

Thanks!

 

Share this post


Link to post
Share on other sites



Have you tried any options on the recovery tab of the service? What happens if you set it to automatically restart the service?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

You probably already compiled-to-exe as a console application, but this might be worth checking.

Share this post


Link to post
Share on other sites

X-L-Ant suggestion on service recovery options. I set all three to restart the service and no joy. I think that is because the service is already started (at least according to SCM).

@clicked I would be happy to try and compile it as a console application if you could give me the How-To. What is a console application?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

While 1
   CheckMainProgram()
   Sleep(2000)
   WEnd

Func CheckMainProgram()
If ProcessExists("Notepad.exe") <>  0 Then
   Return
   EndIf
Beep()
Run("C:\Windows\Notepad.exe")
EndFunc

I have to be doing something amazingly stupid. Above is the code. I turn it in to a service with EXE2Service. I get a beep() when I boot the computer. I can then log in and notepad in there. I can close notepad and it will beep and re-open notepad a million times until I log off. As soon as I log off and log back on SCM tells me the service is started but no beeps, no notepad. Nothing.

Edited by Trax

Share this post


Link to post
Share on other sites

have the service stop on log off and restart on logon.

 

How do you do that? It is almost as if it is already set to stop at logoff but in a wierd way. The service stops at logoff but when I log back on SCM says the service is"started" but it isn't running. As mentioned I have to restart the service after logging back on.

Your suggestion would be perfect if I could find out how to do that :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0