Führen Sie den Prozess im Remote -Computer mit einem fehlgeschlagenen WMI ausC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Führen Sie den Prozess im Remote -Computer mit einem fehlgeschlagenen WMI aus

Post by Anonymous »

Ich bin ein Administrator und möchte Helpdesk -Sachen delegieren, um einige Anwendungen zu machen, die stille Installationen durchführen, die Administrator benötigen. Rechte, ich habe den folgenden Code ausprobiert und erhält immer die Fehlermeldung 'RPC -Server ist nicht verfügbar. Ich kann nicht herausfinden, was mit meinem Code falsch ist. Jede Hilfe wird sehr geschätzt. < /p>

Code: Select all

  public static string ahmed(string machine, string username, string password, string domain)
{
try
{
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.Authority = "ntlmdomain:" + domain + @"\" + machine;
connectionOptions.Username = username;
connectionOptions.Password = password;
connectionOptions.Impersonation = ImpersonationLevel.Delegate;
connectionOptions.Authentication = AuthenticationLevel.PacketPrivacy;

//define the WMI root name space
ManagementScope scope = new ManagementScope(@"\\" + machine + "." + domain + @"\root\CIMV2", connectionOptions);

//define path for the WMI class
ManagementPath p = new ManagementPath("Win32_Process");

//define new instance
ManagementClass processClass = new ManagementClass(scope, p, null);

// Create an array containing all
// arguments for the method
object[] methodArgs =
{@"mkdir c:\testtest", null, null, 0};

//Execute the method
object result =
processClass.InvokeMethod(
"Create", methodArgs);

return "done";
}
catch (ManagementException me)
{
return me.Message;
}

catch (COMException ioe)
{
return ioe.Message;
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post