Please help me out how to create hidden GUI application and use the CreateProcessAsUser function to run the application within the context of the interactive user.
Please refer below link for Interactive services(Windows)
Inetractive Services(Windows) Provide some inputs how to create
1) Display a dialog box in the user's session using the WTSSendMessage function. 2) Create a separate hidden GUI application and use the CreateProcessAsUser function to run the application within the context of the interactive user.
Design the GUI application to communicate with the service through some method of interprocess communication (IPC).
First and foremost, CreateProcessAsUser is a pretty tough Windows API, if you ask me. You might get a better response on some MSDN forum.
If decide to go this way, you need to use a mechanism to call native libraries (eg. JNI, JNA or something similar) to be able to call Windows API. There isn't anything special about calling this function compared to other native functions, the problem is understanding and setting up its parameters correctly. Setting up the security attributes will probably be the hardest part of it.
Depending on your needs, you may be able to do without CreateProcessAsUser. This call lets your service to start a GUI application which can then interact with the user in any way it wants. If you let the user start the application instead, or put the app into the Startup folder, you may avoid using CreateProcessAsUser. The problem in this case is that if the service wants to communicate with the user and the GUI application is not running, it doesn't have any means to let it be known. It's up to you to decide whether this presents a problem or not. You could probably use the WTSSendMessage function (which I assume is easier to use) to alert the user that he needs to run your GUI application.
(A note: Java is not the best suited language for Windows services, in my opinion.)