How do i send CMD system commands from a windows form application?

Me 141 Reputation points
2022-06-11T04:01:05.107+00:00

Hello, i would like to know how to send system commands like taskkill or other commands with a press of a button from a windows form application.

Here is what i'm trying to do.

I have a roblox injector which executes scripts, but i want a button that does these commands:
taskkill /im robloxplayerlauncherbeta.exe /f
taskkill /im robloxplayerlauncher.exe /f
taskkill /im robloxstudio.exe /f
Here are screenshots of my button and my button's code.
210359-image.png
210387-image.png

Please give an answer.

Edit: im trying to do os.system, but it doesnt work.

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,406 Reputation points
    2022-06-11T07:11:17.59+00:00

    You can use Process.Start, like :

                    using (Process p = new Process())  
                    {  
                        p.StartInfo.FileName = "taskkill";  
                        p.StartInfo.Arguments = "/im notepad.exe /f";  
                        p.StartInfo.CreateNoWindow = true;  
                        p.StartInfo.UseShellExecute = false;  
                        p.Start();  
                    }  
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.