My problem is the interaction with exec.command. I would like to automate RunAs on windows.
I want via this application launch other applications (eg Ccleaner, antivirus eset online, etc …) on computers of my clients. So I create a adminsys account and I want to launch these various applications automatically with this account.
cmd := exec.Command("runas", user, nameProgram)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
stdin, err := cmd.StdinPipe()
if err != nil {
fmt.Println(err)
}
defer stdin.Close()
err = cmd.Start()
if err != nil {
fmt.Println(err)
return
}
time.Sleep(3 * time.Second)
io.WriteString(stdin, password)
err = cmd.Wait()
if err != nil {
fmt.Println(err)
return
}
This does not work!
The errors with runas.
Erreur de RUNAS : Impossible d’exécuter - C:\program.exe
1326 : Le nom d’utilisateur ou le mot de passe est incorrect.
It looks like he does not recognize the password. This works when I do it directly in the command prompt –