Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsAnInteractiveSession() returns false for commands run under "local system" #2

Closed
btrepp opened this issue Jan 12, 2017 · 1 comment

Comments

@btrepp
Copy link

btrepp commented Jan 12, 2017

The following code prints true when ran as a user,
Running it from a shell obtained via "psexec -i -s cmd.exe" . Returns false.

This is an issue in gitea (and most likely gogs) as they run the service using minwinsvc, then call the same binary to do some subtasks (somewhat like how git functions).

This causes the init code to run, (with Os.exit()) when the command is being executed in a shell, and should be not ran as a service at this point.

package main


import (
        "fmt"
        "golang.org/x/sys/windows/svc"
)

func main(){
   interactive, err := svc.IsAnInteractiveSession()
   if(err !=nil){
     panic(err)
 
   }
 
   fmt.Printf("%t\n",interactive);
}
@kardianos
Copy link
Owner

Huh. I'm not sure I would call psexec an interactive service. Really, this actually is called from a service when called from psexec. You'll need an alternate flag or method to deal with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants