Running application in an interactive session from a non-interactive one without admin privileges

Today a short trick. Imagine that you would like to start an application in some specific user session via a PHP script (or any other script running in a non-interactive session). I was googling for that and found many solutions, none of which worked worked without admin privileges. They included PsExec, PowerShell, some other remoting tools. Today a simple solution doing the job.

Idea is: we’ll create a task scheduler task, run it, and then remove. So the code is like this:

This works and runs the application in an interactive session of the user.

How do you run this from IIS server? You need to enable loading user profile by the app pool, then configure windows authentication and you’re done. Confirmed with a simple PHP script doing the job.

Since this runs a thing in an interactive session, you can now use it to run anything with cmd /c yourBatFile which in turn can run the app on a specific virtual desktop (either Win 10 desktop or the one created via WinAPI).