Command Reimplementation C#/C

You can reimplement pretty much all of the Windows command in C and C# to avoid using cmd.exe /c or powershell.

- Listing process in C#

class Program
{
	static void Main(string[] args)
	{
		Process[] processList = Process.GetProcesses();
		foreach (Process p in processList)
		{
			Console.WriteLine(String.Format("{0} {1}", p.Id, p.ProcessName));
		}
}

- Obtain DCs

static void Main(string[] args)
{
	IPHostEntry ihe = Dns.GetHostByName(args[0]);
	IPAddress[] ia = ihe.AddressList;
	for(int i = 0; i < ia.Length; i++)
	{
		Console.WriteLine("Address {1}", i, ia[i].ToString());
	}
}

Last updated