Skip to content

The Demo project isn't working for me (GetSessionUserToken failed) #33

@gte2723

Description

@gte2723

I'm sure I'm not doing something correct, here is what I've done. I downloaded the file CreateProcessAsUser-master.zip and opened it in VS2015. I tried running it unmodified and received the message "Cannot start service from the command line or a debugger. A Windows Service must first be installed and then started ..."

So I created a service with Powershell and changed the first line below to the second:

this.ServiceName = "Service1";
this.ServiceName = "AdminService";

and I get the same error. I wanted to get the demo working before I tried to use this with an MVC website and wrap it in an Invoke-Command powershell command similar to this https://rzander.azurewebsites.net/create-a-process-as-loggedon-user/ . I've searched and it appears the demo works for everyone.

Could my (work) environment be configured incorrectly, not allowing this demo project to work? I am an admin on this box.

if (!GetSessionUserToken(ref hUserToken)) is equal to {0}

[edit: a little more information]

When using the powershell link above and inside of a powershell IDE, I get the following error

Exception calling "StartProcessAsCurrentUser" with "1" argument(s): "StartProcessAsCurrentUser: GetSessionUserToken failed."
At C:\Users\xxx\AppData\Local\Temp\2\6ca92ace-e967-4153-a04c-eab859a2430f.ps1:292 char:1

  • [procs.ProcessExtensions.ProcessExtensions]::StartProcessAsCurrentUse ...
  •   + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : Exception
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions