Windows Service Only Runs When Logged In

I am trying to run an EXE file as a service with no user logged into the server. I have created the service and it starts up without a problem.

The problem is that the service only runs correctly when the user is logged in. This behavior is the same regardless of whether the service runs as an administrator or restricted user.

The EXE copies files from one directory to another. I verified that the user has permissions to both directories.

If I log in as the user and run the EXE file, it copies the files. Are there any Windows permissions (Group Policy or Local Settings) that may be preventing the EXE file from running as a service?


Solution 1:

Service exes need to be specifically written to be services—the start up to ensure integration with the Service Control Manager (SCM) is completely different.

This is the same kind of difference between a GUI application and a command line application.

It is possible, often with command line switches, to support multiple "modes of operation", but this is rarely done.

If the exe is not written to be a service (you should be seeing event log entries about it being shutdown due to not interacting with the SCM correctly) then consider using Task Scheduler to execute it.