don't fail if user is not logged in closes amidaware/tacticalrmm#1573

This commit is contained in:
wh1te909 2023-07-30 13:19:56 -07:00
parent 836c274e83
commit 7f9e3f0f7d

View File

@ -161,12 +161,11 @@ func (a *Agent) RunScript(code string, shell string, args []string, timeout int,
cmd := exec.Command(exe, cmdArgs...)
if runasuser {
token, err := wintoken.GetInteractiveToken(wintoken.TokenImpersonation)
if err != nil {
return "", err.Error(), 66, err
}
if err == nil {
defer token.Close()
cmd.SysProcAttr = &syscall.SysProcAttr{Token: syscall.Token(token.Token()), HideWindow: true}
}
}
cmd.Stdout = &outb
cmd.Stderr = &errb