I want to connect to rRemote PC running Windows 10, from another PC using ManagementScope on a local network.

MiPakTeh 1,476 Reputation points
2023-11-03T14:00:03.67+00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.DirectoryServices;
using System.Drawing;
using System.Linq;
using System.Management;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2Com_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ConnectionOptions options = new ConnectionOptions();
            options.Username = "";
            options.Password = "";

            ManagementScope scope = new ManagementScope("\\\\192.168.0.139\\root\\cimv2", options);
            scope.Connect();
            scope.Options.EnablePrivileges = true;
            scope.Options.Impersonation = System.Management.ImpersonationLevel.Impersonate;
        }
    }


}

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,029 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.