-
-
Notifications
You must be signed in to change notification settings - Fork 366
Process TPC Support & Kill Retry as Admin #1320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this feature. There're some style issues that worth taking a look.
I am not pretty familiar with WMI so I may take a look on that later.
string commandArgument = string.Format("/c netstat -an -o -p tcp|findstr \":{0}.*LISTENING\"", port); | ||
|
||
string commandOut = ExecuteCommandAndCaptureOutput(COMMAND_EXE, commandArgument); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that netstat is a exe that can be called directly without cmd. Could you take a try?
Sorry I didn't see the findstr before. Though, I still think we shall be able to process the string directly with either regex or a manually written parser.
} | ||
|
||
// split host:port | ||
var hostPortTokens = stringTokens[1].Split(new char[] { ':' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to have multiple port in one line? Or that won't happen for Listening port?
process.StartInfo.RedirectStandardError = true; | ||
process.Start(); | ||
|
||
commandOut = process.StandardOutput.ReadToEnd(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be stuck if the process never ends. I think we should put it lower after waiting process ends. Also, probably make this part async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thank you very much for reviewing and pointing out the problems 😊, but in addition to some simple style problems, there are many problems that I can't fix due to my limited ability. You should close this pr, if you have time, can you add these two features🥺?sorry for wasting your precious time. (Actually, I know this code is shit, but I don't have the energy to learn how to write better implementations recently. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the code is that bad. Those things I mention can be adjusted fairly easily.
Though, if you don't have time, I can work on this based on your work for sure (but I probably will not be free to do that for a while).
Thanks for the enhancement idea and an implementation draft!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, then I close this pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leave it here. I will finish it once I got time.
startInfo.FileName = "powershell.exe"; | ||
startInfo.Arguments = $"Start cmd.exe -ArgumentList \"/k\",\"taskkill\",\"/f\",\"/pid\", \"{p.Id}\" -Verb Runas"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget this one. It's pretty weird that you start taskkill
inside a cmd
inside the powershell
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The startInfo do provide an ArgumentList
and Verb
API that worth taking a look.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
Plugin allows searching by listening tcp port
After the kill fails, try to execute it again with administrator privileges
#1317