masterzen / winrm

Command-line tool and library for Windows remote command execution in Go
Apache License 2.0
425 stars 129 forks source link

Title: High CPU and Bandwidth Usage When Running Commands Without Context #168

Open GLWJP opened 2 months ago

GLWJP commented 2 months ago

Hi,

I am currently using an older version of the software and executing commands using the following method:

params := winrm.DefaultParameters
params.TransportDecorator = func() winrm.Transporter { return &winrm.ClientNTLM{} }
client, err := winrm.NewClientWithParameters(endpoint, "xxx", "xxx", params)
client.RunWithString(pshell, "")

I did not use the context like this:

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

I am experiencing high CPU and bandwidth usage with my current approach. Would switching to the RunWithContextWithString method help resolve this issue?

Thank you for your help!