Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save metametaclass/0529fcad4cc10623857361956f4378ca to your computer and use it in GitHub Desktop.
Save metametaclass/0529fcad4cc10623857361956f4378ca to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"os"
"time"
"github.com/masterzen/winrm"
)
func main() {
endpoint := winrm.NewEndpoint("127.0.0.1", 15985, false, true, nil, nil, nil, time.Second*15)
params := winrm.DefaultParameters
params.TransportDecorator = func() winrm.Transporter { return &winrm.ClientNTLM{} }
client, err := winrm.NewClientWithParameters(endpoint, "user", "password", params)
if err != nil {
panic(err)
}
r, err := client.Run("cmd.exe /c dir", os.Stdout, os.Stderr)
if err != nil {
panic(err)
}
fmt.Println(r, "press any key")
fmt.Scanln()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment