Jump to content

compiling EXE to run as a service


UglyBob
 Share

Recommended Posts

I'm trying to create an app which will run as a service and appear in the system tray. I've created the service using SRVANY and it works fine until the user logs off, the app closes down. Initial tests at home made me think I had resolved the issue but in work it still fails, this drove me crazy until I replicated the exact environment, i.e. the version of AutoIT. When using the latest version the script will close everytime a user logs off the PC. I then ran a test with one of the help examples (traycreatemenu) compiled in the latest version and an older version (3.2.4.9) which I was using at home. Lo and behold the script remains when the user logs off then back on etc. using the old version of autoit (aut2exe) but running the same script compiled in the latest version the script closes everytime.

Unfortunately I can't compile my script using the old version of autoit due to the commands and 'includes' used, so I'm stuck.

I've read numerous postings about using SRVANY and even contemplated using the service.au3 options but this although more impressive as a service doesn't work well with GUI's (at least with what I've tried).

There may be something written somewhere in the myriad of text, small print and help which may explain this but does anyone have any ideas as to why an older version of this great tool should allow me run a GUI interactively as a service but the latest not? Is this something to do with complying more rigidly with Microsoft or other coding standards?

"My God, you're looking hideously ugly today, Ugly Bob."

Link to comment
Share on other sites

The only problem with that is the script will then only restart when a user logs back on the PC, if the user logs off and then leaves the PC alone the service (or rather my app which is called by the SRVANY service) will not run.

"My God, you're looking hideously ugly today, Ugly Bob."

Link to comment
Share on other sites

Thanks, but I'm already aware of this and other possible alternatives to executing scripts in windows.

My actual script is a powerdown script. You know, the usual monitor a PC and shutdown if not in use. To be honest this is irrelevant as the actual issue here is the use of compiled scripts as services using the latest version of AutoIT. No matter what I compile the old version works but the new doesn't. I know there are a multitude of similar scripts/software out there but I would like to achieve this little pet project myself if I can. If no-one can shed any light in this issue I might review the script and see if I can re-write it using the commands available in the older version of autoIT.

"My God, you're looking hideously ugly today, Ugly Bob."

Link to comment
Share on other sites

It looks like this whole issue has something to do with 'opt ( "onExitFunc' .....).

With a bit of jiggery-pokery I've got my script working with the older version, and everything works perfectly. I then decided to try and include additional tasks on 'exit'. As soon as I added a function for OnExitFunc and query @EXITMETHOD the script once again closes down when the user logs off. Even with the actual function called contains absolutely nothing it still closes. So, is the latest compiler 'Aut2Exe' adding this or something similar to my script?

This is only info, if it's help for anyone in a similar situation. It would be nice if I could use the current version of AutoIT but am happy to continue using the older version for this particular script of mine.

Edited by UglyBob

"My God, you're looking hideously ugly today, Ugly Bob."

Link to comment
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
 Share

×
×
  • Create New...