Shaitan00 -1 Light Poster

I have a service running as LocalSytem (Service.exe) which is is responsible for launching an interactive application as the logged-on user (USER), to accomplish this I do the following within the Service itself:
- CreateEnvironmentBlock() for the USER
- CreateProcessAsUser(app.exe, USER, password, EnvBlock) as the USER with the corresponding EnvBlock
- DestroyEnvironmentBlock()
- Exit (stop/close) the service

Everything "seems" to work perfectly fine, app.exe starts up and it looks like the user can use it fine (just started really testing it today) - but something has been bothering me and I wanted to check with the guru's and see if I am doing something wrong.

In my steps I create the EnvBlock, start the process (do not wait for it to end, as it could keep running for weeks), and then destroy the EnvBlock and stop the service (no longer needed) - so in reality I am destroying the EnvBlock while the process itself is still running (in the USER context) - is this a bad thing?

Is there a proper way to do this? Because it seems to work fine but I have this gut feeling that something is going to go horribly wrong ... I just want to launch app.exe and then let it go on its merry way as-if it was launched by the USER on the desktop...

Any help or hints would be much appreciated.
Thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.