Created
August 13, 2021 07:17
-
-
Save metametaclass/0529fcad4cc10623857361956f4378ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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