0

I'm trying to run a command on my other pc but I keep getting this error when i run the code.

I have enabled Domain Privilege for Windows Management Instrumentation(WMI) like this post

 var hostname = "myIP"; //hostname or a IpAddress

 var connection = new ConnectionOptions();
 //The '.\' is for a local user on the remote machine
 //Or 'mydomain\user' for a domain user
 connection.Username = "myUsername";
 connection.Password = "Mypass";
 connection.EnablePrivileges = true;
 connection.Impersonation = ImpersonationLevel.Impersonate;
 connection.Authority = "ntlmdomain:" + "myworkgroup";
 connection.Authentication = AuthenticationLevel.Packet;

 object[] theProcessToRun = { anyCommand };


 var wmiScope = new ManagementScope($@"\\{hostname}\root\cimv2", connection);
 wmiScope.Connect();

I can also confirm the other PC is On and connected to the Internet(The same Internet as the PC I'm running my C# program from)

Any Ideas what else I might be missing?

Bamiji O
  • 1
  • 3

1 Answers1

0

1. Please check that your RPC service is not started:

This PC=>Manage=>Service and Applications=>Services=>Remote Procedure Call (RPC), start it (automatically), and the service status is "Start";

2. Please check whether the server-side IIS is installed:

Control Panel=>Programs=>Programs and Features : Turn Windows features on or off=>Internet Information Services

If it still doesn't work after installation try restarting IIS

3. If you are using TestDirector, please try the following:

(1) Open [Start]-[Run] in the TD application server, enter the Dcomcnfg.exe command to open the distributed COM configuration properties, and then select [Applications]-[Mercury OTAServer Server]-[Properties]-[Security] -[Edit]-[Show users], add users starting with IUSR_ and TD_IUSER_LOCAL into the user list

(2) Select [Application]-[Mercury OTAServer Server]-[Properties]-[Identity Logo], select User, and change the user name and password to the local administrator account and password.

(3) If the TD server administrator account/password or database has been modified, be sure to modify them back to the account/password when installing TD, otherwise RPC errors will also occur.

wenbingeng-MSFT
  • 1,546
  • 1
  • 1
  • 8
  • Hi, tried what you suggested and got System.Runtime.InteropServices.COMException: 'A required privilege is not held by the client. (0x80070522)' is there any other thing i could be missing? – Bamiji O Aug 30 '23 at 09:35
  • @BamijiO Hi, which step did you perform when this issue occurred? – wenbingeng-MSFT Aug 31 '23 at 09:08
  • I performed step one and two. I think there just might be some issues with my other PC. Ive tried PsExec(PsTools) as well, no dice – Bamiji O Aug 31 '23 at 20:20