
ObjSearcher = new ManagementObjectSearcher MyScope = new ManagementScope( \\" + machineName \ROOT\CIMV2", connOptions) MyScope = new ManagementScope( \ROOT\CIMV2", connOptions) ĬonnOptions.Username = myDomain + " \\" + userName ĬonnOptions.Username = machineName + " \\" + userName Create the management scope with given credentials Here we can connect to machine by using domain credentials or by using // machine specific credentials if (machineName.ToUpper() = ()) MachineName = cmdMachinesInDomain.SelectedText ĬonnOptions.Impersonation = ImpersonationLevel.Impersonate

MachineName = () Įlse if (cmdMachinesInDomain.SelectedText != string.Empty) If (cmdMachinesInDomain.SelectedItem != null) SingleColWidth = width / dt.Columns.Count This is a very important function as it actually connects to a remote machine and calls a WMI specific query. Remove preceding "CN=" character stringĬ(de.Name.Remove( 0, 3)) ĭirectoryEntry de1 = src.GetDirectoryEntry() Ĭ(()) ĭe1.()) SearchResultCollection results = searcher.FindAll() ĭirectoryEntry de = sr.GetDirectoryEntry() Searcher.Filter = ( " (objectclass=computer)") SearchResultCollection src = userSearcher.FindAll() UserSearcher.Filter = ( " (objectclass=user)") UserSearcher = new DirectorySearcher(entry) Create a user searcher by using filter Private void btnGetMachines_Click( object sender, EventArgs e)Įntry = new DirectoryEntry( " LDAP://" + cmbDomainList.Text) This method is used to get all machines available on the domain: Private DataColumn dc = new DataColumn Important Functions Following are active directory objects to search users and computers private DirectoryEntry entry Used to create new process on remote machine private ManagementClass manageClass Handled management events private ManagementOperationObserver opsObserver Retrieve list of management object based upon specific query private ManagementObjectSearcher objSearcher

Connection options to set user credentials private ConnectionOptions connOptions Scope of the WMI operations private ManagementScope myScope Hashtable to maintain list of machines and related users private Hashtable hs = new Hashtable() To list the processes running a particular image file: TASKlist /S remoteServer /u userName /FI "IMAGENAME eq filename"Įxample: To get the list of processes running cmd.exe on the remote computer 10.132.79.23, the command is: c:\>Tasklist /S 10.132.79.23 /u administrator /FI "IMAGENAME eq CMD.// List of domains that will be loaded in a combobox private string domains = To get list of all the processes, the command is : tasklist /s remoteServer /u userName We can get the remote processes list using tasklist command. taskkill /s remoteServer /u userName /FI "USERNAME eq userLoginId" Viewing the list of processes on remote computer Instead of ‘ imagename‘, now we use ‘ username‘ in the filter argument. The command is similar to the previous case with one change. If you need to kill outlook process, the command would be: taskkill /s 10.132.79.23 /u administrator /FI "IMAGENAME eq OUTLOOK.EXE" Kill processes executed by a particular user taskkill /s 10.132.79.23 /u administrator /FI "IMAGENAME eq CMD.EXE"


taskkill /s remoteServer /u userName /FI "IMAGENAME eq filename"įor example, if I need to kill all command window processes, I would run the below command. We can use filter option (/FI) to specify the image name. This will allow the command to be executed from a batch file, without any user interaction.
#PROCESS EXPLORER REMOTE MACHINE PASSWORD#
We can add /P switch to the above command, to specify the password in the command itself. We can as well specify FQDN name of the computer for /S option. SUCCESS: The process with PID 5088 has been terminated. Type the password for administrator:******
