Starting an application from a Service
I have written a service that works perfectly on my desktop and my test machine both of which are Windows XP Pro, however when I install it on a Windows 2K3 server it has a problem.
The service does the following;
When the service starts it checks to see if my application is running, if it is running it does nothing. Otherwise it starts the application it also has a timer that checks every X minutes to see if the application is still running and restarts it if it is not running. This is all fine.
The problem is that when the service calls the application on the 2K3 server the user interface is not displayed. I have read about this occuring with Vista and the only solution mentioned was using the function CreateProcessAsUser, which is a VC function.
The question is, is there any similar function in VB.net or some other solution to this problem.
I don't know exactly what you're trying to do...so all I can say is that if you want the CreateProcessAsUser type functionality, it is available in .net 2.0. The StartInfo class for the Process object now has a User and Password field. It calls CreateProcessAsUser underneath. Or in .NET 1.1 you can try unmanaged calls to CreateProcessWithLogonW, or you can try to port the following from C++ to VB.NET:
BTW it sounds like the problem is that the user you are running with doesn't have access to the desktop or windowstation objects. Which is the problem that KB165194 is intended to solve I think. I'm not sure if CreateProcessWithLogonW or the new .net 2.0 stuff addresses the security issues involved in running a process as a user from within a service app. If not, then you're stuck porting the c++ code.
Also, if that is the problem, then it's also a problem on your xp machines, you only don't realize it yet. Try seeing what happens when on your xp when your service tries to create a process as user X, when user Y is currently the logged in interactive user. Fails I bet.