murrayju / CreateProcessAsUser

Creates a process in a different Windows session
MIT License
369 stars 114 forks source link

Service not starting without logged in users #15

Closed toqilula closed 6 years ago

toqilula commented 7 years ago

Hi Friends,

I am trying to write a windows service that will reconnect the vpn connection if disconnected, I have implemented your code, and it is working fine only when the users logs in immediately. Otherwise if no user is logged in to windows the service will not start. [see attached event viewer error]

I have tried delayed start, restart service after some time, but non works without users being logged in. Is there any way to bypass that or something. I have done some reading, what about using CreateProcessWithLogonW, instead of CreateProcessAsUser. anyone tried anything like that. Thank you very much in advance guys,

Kind Regards Fatos, Kosovo

error

murrayju commented 6 years ago

You cannot launch interactive applications without an active user desktop session, it simply isn't supported by Windows.

It is possible to register for the windows events for user login, and at that point auto-launch the application.