0

Im trying to make an application which connects to a remote computer using System.Management

An example of my code is here.

String plaintextpassword "238j93q8hfcaishfp9ah9hf3iu4nflkadsujhpg9eh97uhbngfiauefh";
SecureString securepassword = new();
foreach (char c in plaintextpassword)
{
 securepassword.AppendChar(c);
}
ManagementPath path = new MangementPath("\\\\192.168.52.97\\root\\cimv2";
connectionOptions options = new();
options.Impersonation = ImpersonationLevel.Default;
options.SecurePassword = securepassword;
options.Username = "sokmeone";
options.Authentication = AuthenticationLevel.Connect
options.EnablePriviledges = true;

ManagementScope scope = new ManagementScope(path,options);
scope.Connect();

ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
.
.
.

My problem is that i get a

System.Runtime.InteropServices.COMException: 'The stub received bad data. (0x800706F7)'

error.

Does anyone know what im doing wrong ?

0 Answers0