1

I need to create interactive logon session for a user and start an app in this session for this user account. I do not need it to become active session at any point. All I need is having additional session running in the background with an app in it.

Unfortunately LogonUser is not a solution for me because this does not create its own session.

Is there any way of doing it in C#/PInvoke or maybe powershell?

EDIT:

More details on what I am trying to achieve: I know it is not elegant solution but if I could automate this it would be "a solution".

I have 3rd party application which I want to run multiple times on a single desktop. I have tried shift-right clicking "runs as user" but I am getting error can not access "C:\Users\Default\AppData". PInvoke Logonuser fails with access denied exception. If I switch to another user than multiple instances run without any issues.

Similar to XP solution: Create an interactive logon session

Community
  • 1
  • 1
Marek
  • 2,419
  • 6
  • 34
  • 38
  • This sounds like it could be a [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem), what are you doing that creating a new interactive logon session is the solution? – Scott Chamberlain Dec 17 '13 at 15:47
  • I have 3rd party application which I want to run multiple times on a single desktop. I have tried shift-right clicking "runs as user" but I am getting error can not access "C:\Users\Default\AppData". PInvoke Logonuser fails with access denied exception. If I switch to another user than multiple instances run without any issues. – Marek Dec 17 '13 at 15:55
  • I would recommend looking in to using the [Application Compatibility Toolkit](http://technet.microsoft.com/en-us/library/cc722055%28v=ws.10%29.aspx), there is likely a [shim](http://technet.microsoft.com/en-us/library/dd837644%28v=ws.10%29.aspx) you can use that redirects calls to `AppData` to a different location. – Scott Chamberlain Dec 17 '13 at 16:00

2 Answers2

2

I need to create interactive logon session for a user and start an app in this session for this user account.

As I understand it, you cannot create a new session programmatically. You are entitled to create a new desktop, but not a new session.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • What is the difference between new desktop and new Session. Can I use new desktop to run application as a user? – Marek Dec 17 '13 at 16:05
  • There are sessions, window stations and desktops. It can be a bit bewildering. What you can do is create a new desktop and just not activate it. I have no idea whether or not that will solve your actual problem. I've just tried to answer the question that you asked. – David Heffernan Dec 17 '13 at 16:11
  • 1
    Issue came back haunting me. Are you sure it is not possible? How does logmein and other apps can log you into remote computer than? – Marek Jan 03 '14 at 16:39
  • They use remote desktop / terminal services APIs, WTSxxx API functions. They don't make new sessions. – David Heffernan Jan 03 '14 at 16:41
1

I am also having a similar issue, I wrote an app that uses TestStack.White to control a 3rd WPF application which under the hood uses UI Automation. When I RPD into the remote machine and watch the app it runs perfect but as soon as I disconnection or even minimize the RPD window my app freezes. I even tried software like AlwaysUp and Service+ which claim to be able to do this, they can even launch the app into a specific session. Once it does you see this popup which says the application wants to send you a message and unless you view the message the app wont run. I did find a crappy work around using TightVNC. I installed the Server on the remote machine, connected the viewer on my machine then started the app and it remains running even when I disconnect the viewer. TightVNC just created a C# api which I'm waiting for them to send, I'm really hoping I can pragmatically connect a viewer session and start/restart the application. I know this is a little different than what you trying to do and this is an old post but I figured I'd share.

PWS
  • 101
  • 1
  • 1
  • 5