my C sharp is dull

Zedicus

[H]ard|Gawd
Joined
Nov 2, 2010
Messages
1,337
i can not get my ouptup box to show multiple line responses. this should show all installed software by name in the textbox but i only get 1 output line showing up.


Code:
                    ConnectionOptions connProd = new ConnectionOptions();
                    //connection.Username = userNameBox.Text;
                    //connection.Password = passwordBox.Text;
                    //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

                    ManagementScope scopeProd = new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", connProd);
                    scopeProd.Connect();

                    ObjectQuery queryProd = new ObjectQuery(
                        "SELECT * FROM Win32_Product");

                    ManagementObjectSearcher searcherProd =
                        new ManagementObjectSearcher(scopeProd, queryProd);

                    foreach (ManagementObject queryObjProd in searcherProd.Get())
                    {
                        txtProd.Text = queryObjProd["Name"].ToString (); 
                        
                        
                    }
 
that is because the txtProd.Text is being assigned to the current value from the loop and not making a list of them, try...
txtProd.Text += queryObjProd["Name"].ToString();

You will likely need to add in a line feed as well if you want one per line...
txtProd.Text += queryObjProd["Name"].ToString()+Environment.NewLine;
 
BEAUTIFUL!! that worked perfectly!

(counting the time it took to get visual studio installed today is the third day i have been messing with C#, and this is the first textbox output i have done so i figured it was some silly thing that i just have not used yet)

thanks again.
 
It looks like there are potentially tons of items in the collection you're looping through, so you'll want to use a StringBuilder there instead of string concatenation. Since you're new to C# land, it's a good habit to get into.
 
It looks like there are potentially tons of items in the collection you're looping through, so you'll want to use a StringBuilder there instead of string concatenation. Since you're new to C# land, it's a good habit to get into.



i just switched this one to
"SELECT Name FROM Win32_Product"

i do have one entry where i actually am using an * and pulling all fields but i am writing out probably more than 3/4 of them so i figured it was justifiable in that instance.


thanks again.
 
heres the entire thing, for your amusement. its hideous right now and the huge chunks of comments are designs i didnt use but i kept most of it in there for examples incase i needed it.


Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;

namespace wmi
{
    public partial class Form1 : Form
    {
        string computerName;

        
        
        public Form1()
        {
            InitializeComponent();
        }




      private void Form1_Load(object sender, EventArgs e)
        {
            
                //            string computerName;
 //               computerName = "fics01";
                //compName.Text;  


                // Build an options object for the remote connection 
                // if you plan to connect to the remote 
                // computer with a different user name 
                // and password than the one you are currently using. 
                // This example uses the default values. 

 //               ConnectionOptions options =
 //                   new ConnectionOptions();

                // Make a connection to a remote computer. 
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the 
                // remote computer.
//                ManagementScope scope =
 //                   new ManagementScope(
                //                "\\\\172.24.101.30\\root\\cimv2", options);
 //               scope.Connect();


                // Get all the disk drives
//                ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");

                // Loop through each object (disk) retrieved by WMI
//                foreach (ManagementObject moDisk in mosDisks.Get())
                {
                    // Add the HDD to the list (use the Model field as the item's caption)
//                    cmbHdd.Items.Add(moDisk["Model"].ToString());

                }

            }

 

        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        public void StartApp()
        {

            {

                //            string computerName;
//                computerName = "fidca01";
                computerName = compName.Text;
 


                // Build an options object for the remote connection 
                // if you plan to connect to the remote 
                // computer with a different user name 
                // and password than the one you are currently using. 
                // This example uses the default values. 

                ConnectionOptions options =
                    new ConnectionOptions();

                // Make a connection to a remote computer. 
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the 
                // remote computer.
                ManagementScope scope =
                    new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", options);

                //                "\\\\172.24.101.30\\root\\cimv2", options);
                scope.Connect();

                //Query system for Operating System information
                ObjectQuery query = new ObjectQuery(
                    "SELECT * FROM Win32_OperatingSystem");
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);

                ManagementObjectCollection queryCollection = searcher.Get();
                foreach (ManagementObject m in queryCollection)
                {
                    // Display the remote computer information

                    lblCNam.Text = "Hostname: " + m["csname"].ToString();
                    lblWinDir.Text = "Win Dir: " + m["WindowsDirectory"].ToString();
                    lblCap.Text = "OS: " + m["Caption"].ToString();
                    lblMan.Text = "Manufacturer: " + m["Manufacturer"].ToString();
                    lblVer.Text = "Version: " + m["Version"].ToString();

                    //Console.WriteLine("Computer Name : {0}",
                    //    m["csname"]);
                    //Console.WriteLine("Windows Directory : {0}",
                    //    m["WindowsDirectory"]);
                    //Console.WriteLine("Operating System: {0}",
                    //    m["Caption"]);
                    //Console.WriteLine("Version: {0}", m["Version"]);
                    //Console.WriteLine("Manufacturer : {0}",
                    //    m["Manufacturer"]);
                }
                    
                
                    //Connection credentials to the remote computer – not needed if the logged in account has access
                    ConnectionOptions oConn = new ConnectionOptions();
                    //oConn.Username = "JohnDoe";
                    //oConn.Password = "JohnsPass";

                    System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\" + computerName + "\\root\\cimv2", oConn);    

                    //get Fixed disk stats
                    System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");

                    //Execute the query 
                    ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs,oQuery);

                    //Get the results
                    ManagementObjectCollection oReturnCollection = oSearcher.Get();   
         
                    //loop through found drives and write out info
                    foreach( ManagementObject oReturn in oReturnCollection )
                        {
                        lblType.Text = "Name: " + oReturn["Name"].ToString();
                        lblModel.Text = "Size: " + oReturn["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        lblSerial.Text = "Free: " + oReturn["FreeSpace"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["FreeSpace"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        
                        
                        // Disk name
                        //Console.WriteLine("Name : " + oReturn["Name"].ToString());
                        // Free Space in bytes
                        //Console.WriteLine("FreeSpace: " + oReturn["FreeSpace"].ToString());
                        // Size in bytes
                        //Console.WriteLine("Size: " + oReturn["Size"].ToString());
                        }

                    ConnectionOptions connection = new ConnectionOptions();
                    //connection.Username = userNameBox.Text;
                    //connection.Password = passwordBox.Text;
                    //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

                    ManagementScope scopeAdm = new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", connection);
                    scopeAdm.Connect();

                    ObjectQuery queryAdm = new ObjectQuery(
                        "SELECT * FROM Win32_ComputerSystem");

                    ManagementObjectSearcher searcherAdm =
                        new ManagementObjectSearcher(scopeAdm, queryAdm);

                    foreach (ManagementObject queryObjAdm in searcherAdm.Get())
                    {


                        lblAdmSts.Text = " " + queryObjAdm["AdminPasswordStatus"].ToString();
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("Win32_ComputerSystem instance");
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("AdminPasswordStatus: {0}", queryObjAdm["AdminPasswordStatus"]);
                    }


                    ConnectionOptions connProd = new ConnectionOptions();
                    //connection.Username = userNameBox.Text;
                    //connection.Password = passwordBox.Text;
                    //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

                    ManagementScope scopeProd = new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", connProd);
                    scopeProd.Connect();

                    ObjectQuery queryProd = new ObjectQuery(
                        "SELECT Name FROM Win32_Product");

                    ManagementObjectSearcher searcherProd =
                        new ManagementObjectSearcher(scopeProd, queryProd);

                    foreach (ManagementObject queryObjProd in searcherProd.Get())
                    {
                        //txtProd.Text = queryObjProd["Name"] + "\r\n".ToString ();
                        txtProd.Text += queryObjProd["Name"].ToString() + Environment.NewLine;

                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("Win32_Product instance");
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("Name: {0}", queryObjProd["Name"]);
                    }










                //          Get all the disk drives from WMI that match the Model name selected in the ComboBox

                //          lblType.Text = "-";

                //            ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + cmbHdd.SelectedItem + "'");

                //          Loop through the drives retrieved, although it should normally be only one loop going on here

                //foreach (ManagementObject moDisk in mosDisks.Get())
                //{

                //    //               Set all the fields to the appropriate values
                //    try
                //    {
                //        lblType.Text = moDisk["name"].ToString();
                //    }
                //    catch { }
                //    lblModel.Text = "Model: " + moDisk["Model"].ToString();

                //    lblSerial.Text = "Serial: " + moDisk["SerialNumber"].ToString();

                //    lblInterface.Text = "Interface: " + moDisk["InterfaceType"].ToString();

                //    //               The capacity in gigabytes is easily calculated

                //    lblCapacity.Text = "Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";

                //    lblPartitions.Text = "Partitions: " + moDisk["Partitions"].ToString();

                //    lblSignature.Text = "Signature: " + moDisk["Signature"].ToString();

                //    lblFirmware.Text = "Firmware: " + moDisk["FirmwareRevision"].ToString();

                //    lblCylinders.Text = "Cylinders: " + moDisk["TotalCylinders"].ToString();

                //    lblSectors.Text = "Sectors: " + moDisk["TotalSectors"].ToString();

                //    lblHeads.Text = "Heads: " + moDisk["TotalHeads"].ToString();

                //    lblTracks.Text = "Tracks: " + moDisk["TotalTracks"].ToString();

                //    lblBytesPerSector.Text = "Bytes per Sector: " + moDisk["BytesPerSector"].ToString();

                //    lblSectorPerTrack.Text = "Sectors per Track: " + moDisk["SectorsPerTrack"].ToString();

                //    lblTracksPerCylinder.Text = "Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString();

                //    //                lblCompName.Text = computerName.ToString();


                //}


            }
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            StartApp();

        }

        private void btnGet_Click(object sender, EventArgs e)
        {
            ConnectionOptions connServ = new ConnectionOptions();
            //conn.Impersonation = ImpersonationLevel.Impersonate;
            //conn.Username = txtUsername.Text;
            //conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", connServ);
            ManagementObjectSearcher servSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Service"));

            foreach (ManagementObject servObj in servSearcher.Get())
            {
                lstServices.Items.Add(servObj["Caption"]);
            }
        }

    
    
    
    
    
    
    
    
//    }
//}


//        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
//        {
            //lblType.Text = "-";
            //lblModel.Text = "-";
            //lblSerial.Text = "-";
            //lblInterface.Text = "-";
            //lblCapacity.Text = "-";
            //lblPartitions.Text = "-";
            //lblSignature.Text = "-";
            //lblFirmware.Text = "-";
            //lblCylinders.Text = "-";
            //lblSectors.Text = "-";
            //lblHeads.Text = "-";
            //lblTracks.Text = "-";
            //lblBytesPerSector.Text = "-";
            //lblSectorPerTrack.Text = "-";
            //lblTracksPerCylinder.Text = "-";
//            ManagementObjectSearcher mosDisk = new ManagementObjectSearcher("Select * From Win32_DiskDrive Where Model='" + cmbHdd.SelectedItem + "'");

            //foreach (ManagementObject moDisk in mosDisk.Get())
            //{


            //    try
            //    {
            //        lblType.Text = moDisk["name"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblModel.Text = moDisk["Model"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSerial.Text = moDisk["SerialNumber"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblInterface.Text = moDisk["InterfaceType"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblCapacity.Text = moDisk["Size"].ToString() + "bytes(" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + "GB)";
            //    }
            //    catch { }
            //    try
            //    {
            //        lblPartitions.Text = moDisk["Partitions"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSignature.Text = moDisk["Signature"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblFirmware.Text = moDisk["FirmwareRevision"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblCylinders.Text = moDisk["TotalCylinders"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSectors.Text = moDisk["Totalsectors"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblHeads.Text = moDisk["TotalHeads"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblTracks.Text = moDisk["TotalTracks"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblBytesPerSector.Text = moDisk["BytesPerSector"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSectorPerTrack.Text = moDisk["SectorsPerTrack"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblTracksPerCylinder.Text = moDisk["TracksPerCylinder"].ToString();
            //    }
            //    catch { }


            //}
//        }




    }
}
 
I think this is pretty fucking cool. I used to mess around in C and its been a gazillion years... but this thread has peaked my interest..
 
this app will start and stop remote services, list and uninstall remote application. and list a bunch of remote machine info. based on domain security. most of the stuff to allow login authentication is in there just commented out as i am using logged in user over the domain so i do not need it.

i hunted all over for block commenting, even VS did line comments when i highlighted a block and hit the comment all keys.


new version, more features

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using System.Management.Instrumentation;

namespace wmi
{
    public partial class Form1 : Form
    {
        string computerName;

        
        
        public Form1()
        {
            InitializeComponent();
        }




      private void Form1_Load(object sender, EventArgs e)
        {
            
                //            string computerName;
 //               computerName = "fics01";
                //compName.Text;  


                // Build an options object for the remote connection 
                // if you plan to connect to the remote 
                // computer with a different user name 
                // and password than the one you are currently using. 
                // This example uses the default values. 

 //               ConnectionOptions options =
 //                   new ConnectionOptions();

                // Make a connection to a remote computer. 
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the 
                // remote computer.
//                ManagementScope scope =
 //                   new ManagementScope(
                //                "\\\\172.24.101.30\\root\\cimv2", options);
 //               scope.Connect();


                // Get all the disk drives
//                ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");

                // Loop through each object (disk) retrieved by WMI
//                foreach (ManagementObject moDisk in mosDisks.Get())
                {
                    // Add the HDD to the list (use the Model field as the item's caption)
//                    cmbHdd.Items.Add(moDisk["Model"].ToString());

                }

            }

 

        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        public void StartApp()
        {

            {

                //            string computerName;
//                computerName = "fidca01";
                computerName = compName.Text;
 


                // Build an options object for the remote connection 
                // if you plan to connect to the remote 
                // computer with a different user name 
                // and password than the one you are currently using. 
                // This example uses the default values. 

                ConnectionOptions options =
                    new ConnectionOptions();

                // Make a connection to a remote computer. 
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the 
                // remote computer.
                ManagementScope scope =
                    new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", options);

                //                "\\\\172.24.101.30\\root\\cimv2", options);
                scope.Connect();

                //Query system for Operating System information
                ObjectQuery query = new ObjectQuery(
                    "SELECT * FROM Win32_OperatingSystem");
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);

                ManagementObjectCollection queryCollection = searcher.Get();
                foreach (ManagementObject m in queryCollection)
                {
                    // Display the remote computer information

                    lblCNam.Text = "Hostname: " + m["csname"].ToString();
                    lblWinDir.Text = "Win Dir: " + m["WindowsDirectory"].ToString();
                    lblCap.Text = "OS: " + m["Caption"].ToString();
                    lblMan.Text = "Manufacturer: " + m["Manufacturer"].ToString();
                    lblVer.Text = "Version: " + m["Version"].ToString();
                    lblOstype.Text = m["OSType"].ToString();
                    lblArch.Text = m["OSArchitecture"].ToString();
                    lblRam.Text = m["TotalVisibleMemorySize"].ToString() + " bytes (" + Math.Round((((double)Convert.ToDouble(m["TotalVisibleMemorySize"]) / 1024) / 1024), 2) + " GB)";


                    //Console.WriteLine("Computer Name : {0}",
                    //    m["csname"]);
                    //Console.WriteLine("Windows Directory : {0}",
                    //    m["WindowsDirectory"]);
                    //Console.WriteLine("Operating System: {0}",
                    //    m["Caption"]);
                    //Console.WriteLine("Version: {0}", m["Version"]);
                    //Console.WriteLine("Manufacturer : {0}",
                    //    m["Manufacturer"]);
                }
                    
                
                    //Connection credentials to the remote computer – not needed if the logged in account has access
                    ConnectionOptions oConn = new ConnectionOptions();
                    //oConn.Username = "JohnDoe";
                    //oConn.Password = "JohnsPass";

                    System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\" + computerName + "\\root\\cimv2", oConn);    

                    //get Fixed disk stats
                    System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");

                    //Execute the query 
                    ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs,oQuery);

                    //Get the results
                    ManagementObjectCollection oReturnCollection = oSearcher.Get();   
         
                    //loop through found drives and write out info
                    foreach( ManagementObject oReturn in oReturnCollection )
                        {
                        lblType.Text =  oReturn["Name"].ToString();
                        lblModel.Text =  oReturn["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        lblSerial.Text =  oReturn["FreeSpace"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["FreeSpace"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        
                        
                        // Disk name
                        //Console.WriteLine("Name : " + oReturn["Name"].ToString());
                        // Free Space in bytes
                        //Console.WriteLine("FreeSpace: " + oReturn["FreeSpace"].ToString());
                        // Size in bytes
                        //Console.WriteLine("Size: " + oReturn["Size"].ToString());
                        }

                    ConnectionOptions connection = new ConnectionOptions();
                    //connection.Username = userNameBox.Text;
                    //connection.Password = passwordBox.Text;
                    //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

                    ManagementScope scopeAdm = new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", connection);
                    scopeAdm.Connect();

                    ObjectQuery queryAdm = new ObjectQuery(
                        "SELECT AdminPasswordStatus,UserName FROM Win32_ComputerSystem");

                    ManagementObjectSearcher searcherAdm =
                        new ManagementObjectSearcher(scopeAdm, queryAdm);

                    foreach (ManagementObject queryObjAdm in searcherAdm.Get())
                    {


                        lblAdmSts.Text = " " + queryObjAdm["AdminPasswordStatus"].ToString();
                        lblUser.Text = queryObjAdm["UserName"].ToString();
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("Win32_ComputerSystem instance");
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("AdminPasswordStatus: {0}", queryObjAdm["AdminPasswordStatus"]);
                    }












                //          Get all the disk drives from WMI that match the Model name selected in the ComboBox

                //          lblType.Text = "-";

                //            ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + cmbHdd.SelectedItem + "'");

                //          Loop through the drives retrieved, although it should normally be only one loop going on here

                //foreach (ManagementObject moDisk in mosDisks.Get())
                //{

                //    //               Set all the fields to the appropriate values
                //    try
                //    {
                //        lblType.Text = moDisk["name"].ToString();
                //    }
                //    catch { }
                //    lblModel.Text = "Model: " + moDisk["Model"].ToString();

                //    lblSerial.Text = "Serial: " + moDisk["SerialNumber"].ToString();

                //    lblInterface.Text = "Interface: " + moDisk["InterfaceType"].ToString();

                //    //               The capacity in gigabytes is easily calculated

                //    lblCapacity.Text = "Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";

                //    lblPartitions.Text = "Partitions: " + moDisk["Partitions"].ToString();

                //    lblSignature.Text = "Signature: " + moDisk["Signature"].ToString();

                //    lblFirmware.Text = "Firmware: " + moDisk["FirmwareRevision"].ToString();

                //    lblCylinders.Text = "Cylinders: " + moDisk["TotalCylinders"].ToString();

                //    lblSectors.Text = "Sectors: " + moDisk["TotalSectors"].ToString();

                //    lblHeads.Text = "Heads: " + moDisk["TotalHeads"].ToString();

                //    lblTracks.Text = "Tracks: " + moDisk["TotalTracks"].ToString();

                //    lblBytesPerSector.Text = "Bytes per Sector: " + moDisk["BytesPerSector"].ToString();

                //    lblSectorPerTrack.Text = "Sectors per Track: " + moDisk["SectorsPerTrack"].ToString();

                //    lblTracksPerCylinder.Text = "Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString();

                //    //                lblCompName.Text = computerName.ToString();


                //}


            }
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            StartApp();

        }

        private void btnGet_Click(object sender, EventArgs e)
        {
            ConnectionOptions connServ = new ConnectionOptions();
            //conn.Impersonation = ImpersonationLevel.Impersonate;
            //conn.Username = txtUsername.Text;
            //conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", connServ);
            ManagementObjectSearcher servSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Service"));

            foreach (ManagementObject servObj in servSearcher.Get())
            {
                lstServices.Items.Add(servObj["Caption"]);
            }
        }

        private void btnSoftware_Click(object sender, EventArgs e)
        {
            ConnectionOptions connProd = new ConnectionOptions();
            //connection.Username = userNameBox.Text;
            //connection.Password = passwordBox.Text;
            //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

            ManagementScope scopeProd = new ManagementScope(
                "\\\\" + computerName + "\\root\\cimv2", connProd);
            scopeProd.Connect();

            ObjectQuery queryProd = new ObjectQuery(
                "SELECT Name FROM Win32_Product");

            ManagementObjectSearcher searcherProd =
                new ManagementObjectSearcher(scopeProd, queryProd);

            foreach (ManagementObject queryObjProd in searcherProd.Get())
            {
                //txtProd.Text = queryObjProd["Name"] + "\r\n".ToString ();
                txtProd.Text += queryObjProd["Name"].ToString() + Environment.NewLine;

                //Console.WriteLine("-----------------------------------");
                //Console.WriteLine("Win32_Product instance");
                //Console.WriteLine("-----------------------------------");
                //Console.WriteLine("Name: {0}", queryObjProd["Name"]);
            }

        }



        public ManagementObjectCollection fetchServiceObject(string service)
        {
            ConnectionOptions conn = new ConnectionOptions();
            //conn.Impersonation = ImpersonationLevel.Impersonate;
            //conn.Username = txtUsername.Text;
            //conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", conn);
            ManagementObjectSearcher serviceSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Service where Caption='" + service + "'"));

            return serviceSearcher.Get();     // Returns the service where caption == listbox  selected item     
        }     
  
        private void btnStart_Click(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceObjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceObjs)
            {
                if (service["Started"].Equals(false))
                {
                    service.InvokeMethod("StartService", null);
                    lblState.Text = "Started";
                }
            }
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceObjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceObjs)
            {
                if (service["Started"].Equals(true))
                {
                    service.InvokeMethod("StopService", null);
                    lblState.Text = "Stopped";
                }
            }
        }

        private void lstServices_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceobjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceobjs)
            {
                if (service["started"].Equals(true))
                {
                    lblState.Text = "Started";
                }
                else
                {
                    lblState.Text = "Stopped";
                }
            }
        }

         
        
        //      private void button1_Click(object sender, EventArgs e)
  //      {

  //      }

    
    
    
    
    
    
    
    
//    }
//}


//        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
//        {
            //lblType.Text = "-";
            //lblModel.Text = "-";
            //lblSerial.Text = "-";
            //lblInterface.Text = "-";
            //lblCapacity.Text = "-";
            //lblPartitions.Text = "-";
            //lblSignature.Text = "-";
            //lblFirmware.Text = "-";
            //lblCylinders.Text = "-";
            //lblSectors.Text = "-";
            //lblHeads.Text = "-";
            //lblTracks.Text = "-";
            //lblBytesPerSector.Text = "-";
            //lblSectorPerTrack.Text = "-";
            //lblTracksPerCylinder.Text = "-";
//            ManagementObjectSearcher mosDisk = new ManagementObjectSearcher("Select * From Win32_DiskDrive Where Model='" + cmbHdd.SelectedItem + "'");

            //foreach (ManagementObject moDisk in mosDisk.Get())
            //{


            //    try
            //    {
            //        lblType.Text = moDisk["name"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblModel.Text = moDisk["Model"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSerial.Text = moDisk["SerialNumber"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblInterface.Text = moDisk["InterfaceType"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblCapacity.Text = moDisk["Size"].ToString() + "bytes(" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + "GB)";
            //    }
            //    catch { }
            //    try
            //    {
            //        lblPartitions.Text = moDisk["Partitions"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSignature.Text = moDisk["Signature"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblFirmware.Text = moDisk["FirmwareRevision"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblCylinders.Text = moDisk["TotalCylinders"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSectors.Text = moDisk["Totalsectors"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblHeads.Text = moDisk["TotalHeads"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblTracks.Text = moDisk["TotalTracks"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblBytesPerSector.Text = moDisk["BytesPerSector"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblSectorPerTrack.Text = moDisk["SectorsPerTrack"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblTracksPerCylinder.Text = moDisk["TracksPerCylinder"].ToString();
            //    }
            //    catch { }


            //}
//        }




    }
}
 
Last edited:
fully functional with remote software removal and remote service management. i have some I D 10 T proofing to do, and lots (TONS) of code cleanup. does anyone know of a visual studio host where i could post the complete project? i think this could be a usefull app.

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management;
using System.Management.Instrumentation;

namespace wmi
{
    public partial class Form1 : Form
    {
        string computerName;
        string software;
        
        
        public Form1()
        {
            InitializeComponent();
        }




      private void Form1_Load(object sender, EventArgs e)
        {
            

            }

 

        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        public void StartApp()
        {

            {

                //            string computerName;
//                computerName = "fidca01";
                
                computerName = compName.Text;
 


                // Build an options object for the remote connection 
                // if you plan to connect to the remote 
                // computer with a different user name 
                // and password than the one you are currently using. 
                // This example uses the default values. 

                ConnectionOptions options =
                    new ConnectionOptions();

                // Make a connection to a remote computer. 
                // Replace the "FullComputerName" section of the
                // string "\\\\FullComputerName\\root\\cimv2" with
                // the full computer name or IP address of the 
                // remote computer.
                ManagementScope scope =
                    new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", options);

                //                "\\\\172.24.101.30\\root\\cimv2", options);
                scope.Connect();

                //Query system for Operating System information
                ObjectQuery query = new ObjectQuery(
                    "SELECT * FROM Win32_OperatingSystem");
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher(scope, query);

                ManagementObjectCollection queryCollection = searcher.Get();
                foreach (ManagementObject m in queryCollection)
                {
                    // Display the remote computer information

                    lblCNam.Text = "Hostname: " + m["csname"].ToString();
                    lblWinDir.Text = "Win Dir: " + m["WindowsDirectory"].ToString();
                    lblCap.Text = "OS: " + m["Caption"].ToString();
                    lblMan.Text = "Manufacturer: " + m["Manufacturer"].ToString();
                    lblVer.Text = "Version: " + m["Version"].ToString();
                    lblOstype.Text = m["OSType"].ToString();
                    lblArch.Text = m["OSArchitecture"].ToString();
                    lblRam.Text = m["TotalVisibleMemorySize"].ToString() + " bytes (" + Math.Round((((double)Convert.ToDouble(m["TotalVisibleMemorySize"]) / 1024) / 1024), 2) + " GB)";


                    //Console.WriteLine("Computer Name : {0}",
                    //    m["csname"]);
                    //Console.WriteLine("Windows Directory : {0}",
                    //    m["WindowsDirectory"]);
                    //Console.WriteLine("Operating System: {0}",
                    //    m["Caption"]);
                    //Console.WriteLine("Version: {0}", m["Version"]);
                    //Console.WriteLine("Manufacturer : {0}",
                    //    m["Manufacturer"]);
                }
                    
                
                    //Connection credentials to the remote computer – not needed if the logged in account has access
                    ConnectionOptions oConn = new ConnectionOptions();
                    //oConn.Username = "JohnDoe";
                    //oConn.Password = "JohnsPass";

                    System.Management.ManagementScope oMs = new System.Management.ManagementScope("\\\\" + computerName + "\\root\\cimv2", oConn);    

                    //get Fixed disk stats
                    System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery("select FreeSpace,Size,Name from Win32_LogicalDisk where DriveType=3");

                    //Execute the query 
                    ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs,oQuery);

                    //Get the results
                    ManagementObjectCollection oReturnCollection = oSearcher.Get();   
         
                    //loop through found drives and write out info
                    foreach( ManagementObject oReturn in oReturnCollection )
                        {
                        lblType.Text =  oReturn["Name"].ToString();
                        lblModel.Text =  oReturn["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        lblSerial.Text =  oReturn["FreeSpace"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(oReturn["FreeSpace"]) / 1024) / 1024) / 1024), 2) + " GB)";
                        
                        
                        // Disk name
                        //Console.WriteLine("Name : " + oReturn["Name"].ToString());
                        // Free Space in bytes
                        //Console.WriteLine("FreeSpace: " + oReturn["FreeSpace"].ToString());
                        // Size in bytes
                        //Console.WriteLine("Size: " + oReturn["Size"].ToString());
                        }

                    ConnectionOptions connection = new ConnectionOptions();
                    //connection.Username = userNameBox.Text;
                    //connection.Password = passwordBox.Text;
                    //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

                    ManagementScope scopeAdm = new ManagementScope(
                        "\\\\" + computerName + "\\root\\cimv2", connection);
                    scopeAdm.Connect();

                    ObjectQuery queryAdm = new ObjectQuery(
                        "SELECT AdminPasswordStatus,UserName FROM Win32_ComputerSystem");

                    ManagementObjectSearcher searcherAdm =
                        new ManagementObjectSearcher(scopeAdm, queryAdm);

                    foreach (ManagementObject queryObjAdm in searcherAdm.Get())
                    {


                        lblAdmSts.Text = " " + queryObjAdm["AdminPasswordStatus"].ToString();
                        try
                         {
                             lblUser.Text = " " + queryObjAdm["UserName"].ToString();
                         }
                             catch { }            
                        
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("Win32_ComputerSystem instance");
                        //Console.WriteLine("-----------------------------------");
                        //Console.WriteLine("AdminPasswordStatus: {0}", queryObjAdm["AdminPasswordStatus"]);
                    }



                //          Get all the disk drives from WMI that match the Model name selected in the ComboBox

                //          lblType.Text = "-";

                //            ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + cmbHdd.SelectedItem + "'");

                //          Loop through the drives retrieved, although it should normally be only one loop going on here

                //foreach (ManagementObject moDisk in mosDisks.Get())
                //{

                //    //               Set all the fields to the appropriate values
                //    try
                //    {
                //        lblType.Text = moDisk["name"].ToString();
                //    }
                //    catch { }
                //    lblModel.Text = "Model: " + moDisk["Model"].ToString();

                //    lblSerial.Text = "Serial: " + moDisk["SerialNumber"].ToString();

                //    lblInterface.Text = "Interface: " + moDisk["InterfaceType"].ToString();

                //    //               The capacity in gigabytes is easily calculated

                //    lblCapacity.Text = "Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)";

                //    lblPartitions.Text = "Partitions: " + moDisk["Partitions"].ToString();



                //    //                lblCompName.Text = computerName.ToString();


                //}


            }
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            StartApp();

        }

        private void btnGet_Click(object sender, EventArgs e)
        {
            ConnectionOptions connServ = new ConnectionOptions();
            //conn.Impersonation = ImpersonationLevel.Impersonate;
            //conn.Username = txtUsername.Text;
            //conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", connServ);
            ManagementObjectSearcher servSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Service"));

            foreach (ManagementObject servObj in servSearcher.Get())
            {
                lstServices.Items.Add(servObj["Caption"]);
            }
        }

//this block gets software
        private void btnSoftware_Click(object sender, EventArgs e)
        {
            ConnectionOptions connProd = new ConnectionOptions();
            //connection.Username = userNameBox.Text;
            //connection.Password = passwordBox.Text;
            //connection.Authority = "ntlmdomain:ficont.finneycounty.org";

            ManagementScope scopeProd = new ManagementScope(
                "\\\\" + computerName + "\\root\\cimv2", connProd);
            scopeProd.Connect();

            ObjectQuery queryProd = new ObjectQuery(
                "SELECT Name FROM Win32_Product");

            ManagementObjectSearcher searcherProd =
                new ManagementObjectSearcher(scopeProd, queryProd);

            foreach (ManagementObject queryObjProd in searcherProd.Get())
            {
                //txtProd.Text = queryObjProd["Name"] + "\r\n".ToString ();
                //txtProd.Text += queryObjProd["Name"].ToString() + Environment.NewLine;

                //Console.WriteLine("-----------------------------------");
                //Console.WriteLine("Win32_Product instance");
                //Console.WriteLine("-----------------------------------");
                //Console.WriteLine("Name: {0}", queryObjProd["Name"]);
            }

            foreach (ManagementObject servObjSoft in searcherProd.Get())
            {
                lstSoftware.Items.Add(servObjSoft["Name"]);
            }
        }

        private void btnUnin_Click(object sender, EventArgs e)
        {
            ManagementObjectCollection softwareObj = fetchSoftwareObject(lstSoftware.SelectedItem.ToString());
            foreach (ManagementObject Name in softwareObj)
            {
                try
                {
                    
                         object hr = Name.InvokeMethod("Uninstall", null);
                         lstSoftware.ClearSelected();
                    
                        //return (bool)hr;

                   
                }
                catch (Exception ex)
                {
                    //this program may not have a name property, so an exception will be thrown
                }
            
            
            }
    
        
        
        
        }


        public ManagementObjectCollection fetchSoftwareObject(string software)
        {
            ConnectionOptions conn = new ConnectionOptions();
//            conn.Impersonation = ImpersonationLevel.Impersonate;
//            conn.Username = txtUsername.Text;
//            conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", conn);
            ManagementObjectSearcher softwareSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Product where Caption='" + software + "'"));

            return softwareSearcher.Get();     // Returns the service where caption == listbox  selected item     
        }




//this block for services
        public ManagementObjectCollection fetchServiceObject(string service)
        {
            ConnectionOptions conn = new ConnectionOptions();
            //conn.Impersonation = ImpersonationLevel.Impersonate;
            //conn.Username = txtUsername.Text;
            //conn.Password = txtPassword.Text;
            ManagementScope theScope = new ManagementScope("\\\\" + computerName + "\\root\\cimv2", conn);
            ManagementObjectSearcher serviceSearcher = new ManagementObjectSearcher(theScope, new ObjectQuery("SELECT * FROM Win32_Service where Caption='" + service + "'"));

            return serviceSearcher.Get();     // Returns the service where caption == listbox  selected item     
        }     
  
        private void btnStart_Click(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceObjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceObjs)
            {
                if (service["Started"].Equals(false))
                {
                    service.InvokeMethod("StartService", null);
                    lblState.Text = "Started";
                }
            }
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceObjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceObjs)
            {
                if (service["Started"].Equals(true))
                {
                    service.InvokeMethod("StopService", null);
                    lblState.Text = "Stopped";
                }
            }
        }

        private void lstServices_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            ManagementObjectCollection serviceobjs = fetchServiceObject(lstServices.SelectedItem.ToString());
            foreach (ManagementObject service in serviceobjs)
            {
                if (service["started"].Equals(true))
                {
                    lblState.Text = "Started";
                }
                else
                {
                    lblState.Text = "Stopped";
                }
            }
        }

        private void txtProd_TextChanged(object sender, EventArgs e)
        {

        }


         
        
        //      private void button1_Click(object sender, EventArgs e)
  //      {

  //      }

    
    
//    }
//}


//        private void cmbHdd_SelectedIndexChanged(object sender, EventArgs e)
//        {
            //lblType.Text = "-";
            //lblModel.Text = "-";
//            ManagementObjectSearcher mosDisk = new ManagementObjectSearcher("Select * From Win32_DiskDrive Where Model='" + cmbHdd.SelectedItem + "'");

            //foreach (ManagementObject moDisk in mosDisk.Get())
            //{


            //    try
            //    {
            //        lblType.Text = moDisk["name"].ToString();
            //    }
            //    catch { }
            //    try
            //    {
            //        lblModel.Text = moDisk["Model"].ToString();
            //    }
            //    catch { }
 
            //}
//        }




    }
}
 
CodePlex would probably be your best bet if you are looking for a collaborative environment.
 
i just registered a codeplex page. hopefully i will have a homepage and code uploaded soon. my work, and a few other businesses are using the app so far.

and it will be nice to have a master version available as Ive made so many bugfixes even against my posts on here that i am starting to loose track of versions.
 
Thanks for sharing! I'll definitely take a look at that - looks pretty interesting and useful.
 
For your C# tinkering needs, I also recommend checking out https://dotnetfiddle.net/ . It's not for Windows Forms or WPF apps, but you can run C# console apps in the browser with ease. With tools making it this easy, people really have no excuse not to learn to program :) You may also be able to use it to share your project, though I'm not sure if the required packages are supported in your case.

Speaking of, when I first learned C# a few years ago, I had a good experience running through the first 25-30 of these tutorial videos, and was able to figure everything else I needed out from there- https://www.thenewboston.com/videos.php?cat=15
 
those videos also look like they are using visual studio. for me learning my way around that beast was far worse than the coding part. it is not a requirement to use VS, but if you are going to program in an MS created platform you might as well use MS created tools.
 
here is what was in use before this GUI version was thought up. make it a .bat on your windows box and run it, its still quite useful. no where near as pretty as the current GUI app though.

Code:
@Echo off
Echo.
:menu
ECHO.
ECHO ...............................................
ECHO THIS PROGRAM ONLY WORKS FOR THE DOMAIN THAT THE HOST IS ON!
ECHO PRESS # to select your task.
ECHO ...............................................
ECHO.
ECHO 1 - remote remove software
ECHO 2 - remote process kill
ECHO 3 - EXIT
ECHO 4 - get machine 32 or 64 bit OS
Echo 5 - get remote machine DNS config
ECHO 6 - get drives connected to remote machine
ECHO 7 - get remote OS version
ECHO 8 - remove remote printers
ECHO.
SET /P M=Type 1, 2, 3, 4, 5, or 6, then press ENTER:
IF %M%==1 GOTO :removesoft
IF %M%==2 GOTO :pkill
IF %M%==3 GOTO :end
if %M%==4 GOTO :osbit
if %M%==5 GOTO :dnsconf
if %M%==6 GOTO :drives
if %M%==7 GOTO :osver
if %M%==8 GOTO :rmvprnt
:removesoft
:start
echo.

echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=

wmic /node:%COMPUTERNAME% product get name
echo we will prepare to uninstall. 

echo.

set /P continue=Continue, Start over, Abort?  C/S/A (A will exit)   
if /I "%continue%" == "c" goto :continue
if /I "%continue%" == "s" goto :start
if /I "%continue%" == "a" goto :end

:continue

Echo.
:input
set INPUT=
set /P INPUT=type the exact name of the program to uninstall: %=%
if "%INPUT%"=="" goto input
echo Your input was: %INPUT%

echo.
Echo Uninstalling... 

echo The command [wmic /node:%COMPUTERNAME% product where name="%INPUT%" call uninstall] will run. 


wmic /node:%COMPUTERNAME% product where name="%INPUT%" call uninstall /nointeractive
echo.
@echo command completed. if available, the program %INPUT% was uninstalled.
echo.
echo.....................................
echo.
set /P newmachine=Enter a new machine name or IP?  Y/N/M (N will exit)     
if /I "%newmachine%" EQU "y" goto :start
if /I "%newmachine%" EQU "n" goto :end
if /I "%newmachine%" EQU "m" goto :menu
echo.
echo.....................................
echo.

:pkill
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=

wmic /node:%COMPUTERNAME% process get name

echo.

set /P continue=Continue, Start over, Abort?  C/S/A (A will exit)   
if /I "%continue%" == "c" goto :input2
if /I "%continue%" == "s" goto :menu
if /I "%continue%" == "a" goto :end

:input2
set INPUT2=
set /P INPUT2=type the exact name of the process to kill: %=%
if "%INPUT2%"=="" goto input2
echo Your input was: %INPUT2%

echo.
echo process will die...
wmic /node:%COMPUTERNAME% process where name="%INPUT2%" call terminate
echo.
@echo command completed. if available, the process %INPUT2% was murdered.
echo.
pause
goto :menu


:osbit
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=

wmic /node:%COMPUTERNAME% Path Win32_Processor Get AddressWidth /Format:list
pause
goto :menu

:dnsconf
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=

wmic /node:%COMPUTERNAME% Path Win32_NetworkAdapterConfiguration Get Description^,DNSHostName^,DNSServerSearchOrder /Format:list
pause
goto :menu

:drives
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=
ECHO.
ECHO 0=Unknown, 1=No Root dir, 2=Removable, 3=Local Disk, 4=Network, 5=CD, 6=RAM Disk
wmic /node:%COMPUTERNAME% /Output:STDOUT Path Win32_LogicalDisk Get DeviceID^,Description^,DriveType /Format:list
pause
goto :menu

:osver
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=
ECHO.
wmic /node:%COMPUTERNAME% os get name
pause
goto :menu

:rmvprnt
echo enter a computer name or IP address (and wait patiently)
set COMPUTERNAME=
set /P COMPUTERNAME=
ECHO.
wmic /node:%COMPUTERNAME% printer where "name like '%%ficoprt%%'" delete
wmic /node:%COMPUTERNAME% printer where "name like '%%172.24.101.7%%'" delete
wmic /node:%COMPUTERNAME% printer where "Local='True' and Portname LIKE '172%%'" delete
pause
goto :menu


:end
 
those videos also look like they are using visual studio. for me learning my way around that beast was far worse than the coding part. it is not a requirement to use VS, but if you are going to program in an MS created platform you might as well use MS created tools.

Plus they made VS Community Edition, which is essentially VS Pro, available for free.
 
resharper will change your life too ;) have somebody with a .edu email get a free license for you. I'm on my second .edu address.
 
Back
Top