End Google Ads 201810 - BS.net 01 --> Hi,
I want to run some processes on a remote PC using WMI and C#. One of the PC runs XP SP3 and the other PC runs XP SP2. But I keep getting "access denied" errors. some of the errors are:

1. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

2."error Logon failure:the user has not been granted the requested logon type at this computer."

Both computers are workgroup computers.i have tried the following with no avail.

I use a login with administrative privileges. In addition I have enabled this account to be remote enabled using
dcomcnfg >DCOM Config >Windows Management Instrumentation > properties on the remote computer.

From security options, I changed "Network access:Sharing and security options for local accounts"
to "Classic: Local users authenticate as themselves." on the remote computer
Disabled the fire wall
Note that code works fine on local host.

Can anybody help?



Here is the code I am using

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Local Machine
// ProcessLocal process = new ProcessLocal();
//Remote Machine
string userName = "sara";
string password = "titina";
string domain = null;
string machineName = "192.168.12.20";
ConnectionOptions options = new ConnectionOptions();

if (domain != null)
{
options.Username = domain + "\\" + userName;

}
options.Username = userName;
options.Password = password;


options.Impersonation = ImpersonationLevel.Impersonate;
options.Authentication = AuthenticationLevel.Packet;

options.EnablePrivileges = true;


ManagementScope connectScope = new ManagementScope();
connectScope.Path = new ManagementPath(@"\\" + machineName + @"\root\CIMV2");
connectScope.Options = options;

try {
connectScope.Connect();
}
catch (ManagementException e)
{
Console.WriteLine("An Error Occurred: " + e.Message.ToString());
}
catch (AccessViolationException ee)
{



string processName = "notepad.exe";
Console.WriteLine("Creating Process: " + processName);
Console.WriteLine(process.CreateProcess(processName));

Console.WriteLine("Killing Process: " + processName);
//process.TerminateProcess(processName);
Console.WriteLine("Process Terminated");
Console.ReadLine();


}
}
}
}