The Beauty of Command-line Utilities

I like the way command-line tools can be adapted for automating complex tasks.

For instance, if you had to populate the list of names of computers in your LAN in a combo box, the net.exe command can be utilized with the Process.Start() method in C#

Process netsend = new Process();
netsend.StartInfo.FileName = "net.exe";
netsend.StartInfo.CreateNoWindow = true;
netsend.StartInfo.Arguments = "view";
netsend.StartInfo.RedirectStandardOutput = true;
netsend.StartInfo.UseShellExecute = false;
netsend.StartInfo.RedirectStandardError = true;
netsend.Start();

StreamReader sr = new StreamReader(netsend.StandardOutput.BaseStream, netsend.StandardOutput.CurrentEncoding);

string sss = "";
while ((sss = sr.ReadLine()) != null)
{
if (sss.StartsWith("\\"))
comboBox1.Items.Add(sss.Substring(2).Substring(0, sss.Substring(2).IndexOf(" ")).ToUpper();
}

sr.Close();

Setting the CreateNoWindow property to true hides the console window.

Here is a list of command-line tools that I've found helpful (work in progress) -
Dear Reader, what are your favorite command-line tools?

Comments

Popular posts from this blog

Maven Crash Course - Learn Power Query, Power Pivot & DAX in 15 Minutes

"Data Prep & Exploratory Data Analysis" course by Maven Analytics

Oracle Cloud Infrastructure 2024 Generative AI Professional Course & Certification Exam (1Z0-1127-24)