I am trying to implement the *runas /netonly* windows application in go 
lang.
Below I have attached the source code.

package main

import (
    "fmt"
    "os/exec"

    "github.com/itchio/ox/syscallex"
)

func Start(args ...string) (p any, err error) {
    if args[0], err = exec.LookPath(args[0]); err == nil {
        var procAttr syscallex.ProcAttr
        procAttr.Dir = "c:\\Users\\coolb"
        procAttr.Sys = &syscallex.SysProcAttr{
            CreationFlags: syscallex.CREATE_NEW_CONSOLE,
            LogonFlags:    syscallex.LOGON_CREDENTIALS_ONLY,
        }
        p, _, err = syscallex.StartProcessWithLogon(args[0], args, "test", 
"test", "test", &procAttr)
        if err != nil {
            fmt.Printf("Error in StartProcess: %s\n", err)
        } else {
            fmt.Printf("Starting process with pid=%d", p)
        }
    }
    return nil, err
}
func main() {
    if _, err := Start("powershell"); err != nil {
        panic(err)
    }
}

Any advice would be very helpful.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e268f290-de7b-495f-8437-d479047a31fcn%40googlegroups.com.

Reply via email to