简体   繁体   中英

Retrieve processes information remote computer using C#

I'm developing a desktop application using C# language. I'm trying to retrieve all the current active processes on the remote computer with the following code:

else if (infocomboBox.SelectedIndex == 2)
            {
                string compname = compnameLabel.Text;
                Process[] remoteAll = Process.GetProcesses(compnameLabel.Text);
                foreach (Process process in remoteAll)
                {
                    ListViewItem item = new ListViewItem(process.ProcessName);
                    item.Tag = process;
                    listProcessView.Items.Add(item);
                }

            }

I put the code inside the button_click function.

I can't seem to retrieve it with an error saying "InvalidOperationException was unhandled" "Couldn't connect to remote machine"

Log in username and password is disabled on the remote computer. Firewall and antivirus are off also.

Refer below for the error screenshot

Screenshot of the error

What is exactly the problem? Can anybody give solution?

Thank you very much in advance!

I would try to verify from a command line that the hostname is resolvable.

ping theOtherComputerName

If that resolves to an IP address and responds then you've eliminated one possible issue. Next up would have to be connection issues.

I believe the GetProcesses command tries to login to the remote machine using the current username and password, so you would need the same username and password on the other machine,

OR you'll need to impersonate an admin user on the remote machine doing something like this impersonate user in c#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM