Categories
.net Networking programming Recommended Software Solutions tips Windows scripting

The proper way to run a remote process

This is the story of my journey to find a way to run a process (or a program on a remote pc)
This wasn’t an easy thing at all…
Overall, I thought, this should be an easy thing to do.
I found this C# code on a Microsoft forums

object[] theProcessToRun = { "notepad.exe" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Username = "username";
theConnection.Password = "password";
ManagementScope theScope = new ManagementScope("<\\\\" + IP + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);

I tried this code, not after forgetting to disable the firewall on the remote computer – a big downside but I guess if I had gone with it I’d hunt a way to stable port to unblock in the firewall.
 
Then I found the big downside (which can be an upside to some of you):
The remote process this way will never have a GUI window opened (In this example, a process of notepad will be opened in the background).
This can be a big advantage to system admins which want to run scripts.
 
Ok, back to the quest.

Categories
.net Networking programming Solutions

Scanning your entire LAN for MAC Addresses

Not too long ago, I wrote a network administration utility with specific needs.
One of the needs was to scan all the LAN pool for MAC addresses.
The code will look at your active network adapters, calculate start and end IP according to your address and netmask,
and query all the IPs within that range for their MAC address.
The code is written in C#, and it’s basically going over the whole range in a nested loop.
If you find this useful, you are welcome to use the code: