AamirKhurshid

I am using This Code and Getting Exception

Check host name and configure firewall options. Details: RPC server Unavailable

public void RemoteMSI(string machine, string msi, string commandline, string username, string password, string domain)

{

machine=listViewHostNames.FocusedItem.Text;

MessageBox.Show(" Computer........"+machine);

MessageBox.Show("Path.........."+msi );

MessageBox.Show("Command Line......."+commandline );

MessageBox.Show("User Name......."+username );

MessageBox.Show("Pass....."+password );

MessageBox.Show("Domain......"+domain );

try

{

ConnectionOptions connection =

new ConnectionOptions();

connection.Authority = "kerberos:" + domain + @"\" + machine;

//connection.Authority = "NTLMdomain:" + domain;

connection.Username = username;

connection.Password = password;

connection.Impersonation = ImpersonationLevel.Delegate;

connection.Authentication = AuthenticationLevel.PacketPrivacy;

//@@@@@@22

connection.EnablePrivileges = true;

//define the WMI root name space

ManagementScope scope =

new ManagementScope(@"\\" + machine + @"\root\cimv2", connection);

//@@@@@@@@

try

{

scope.Connect();

MessageBox.Show("Connected");

}

catch (System.Runtime.InteropServices.COMException comException)

{

MessageBox.Show( "Server does not exists or access denied. Check host name and configure firewall options. Details: " + comException.Message

+ Environment.NewLine + comException.StackTrace);

}

catch (UnauthorizedAccessException authException)

{

MessageBox.Show( "Access denied or timeout expired. Check if username, password and domain are correct and if user is a member of domain Administrators group. Details: " +

authException.Message + Environment.NewLine + authException.StackTrace);

}

catch (Exception ex)

{

MessageBox.Show( "Unexpected error occurred. Details: " + ex.Message + Environment.NewLine + ex.StackTrace);

}

//@@@@@@@@@

//define path for the WMI class

ManagementPath p =

new ManagementPath("Win32_Product");

ObjectGetOptions ogo = new ObjectGetOptions();

//define new instance

ManagementClass classInstance = new ManagementClass(scope, p, ogo);

// Obtain in-parameters for the method

ManagementBaseObject inParams = classInstance.GetMethodParameters("Install");

MessageBox.Show("Before Case");

// Add the input parameters.

inParams["AllUsers"] = true; //to install for all users

inParams["Options"] = commandline; //paramters must be in the format ˇ°property=settingˇ°

inParams["PackageLocation"] = msi; //source file must be on the remote machine

// Execute the method and obtain the return values.

ManagementBaseObject outParams = classInstance.InvokeMethod("Install", inParams, null);

// List outParams

string retVal = outParams["ReturnValue"].ToString();

string msg = null;

MessageBox.Show("Before Case");

switch (retVal)

{

case "0":

msg = "The installation completed successfully.";

break;

case "2":

msg = "The system cannot find the specified file. \n\r\n\r" + msi;

break;

case "3":

msg = "The system cannot find the path specified. \n\r\n\r" + msi;

break;

case "1619":

msg = "This installation package \n\r\n\r " + msi + "\n\r\n\rcould not be opened, please verify that it is accessible.";

break;

case "1620":

msg = "This installation package \n\r\n\r " + msi + "\n\r\n\rcould not be opened, please verify that it is a valid MSI package.";

break;

default:

msg = "Please see... \n\r\n\r http://msdn.microsoft.com/library/default.asp url=/library/en-us/msi/setup/error_codes.asp \n\r\n\rError code: " + retVal;

break;

}

// Display outParams

MessageBox.Show(msg, "Installation report");

}

catch (ManagementException me)

{

MessageBox.Show(me.Message, "Management Exception");

}

catch (COMException ioe)

{

MessageBox.Show(ioe.Message, "COM Exception");

}

}

Help Me out ......

Any Idea ..

Regards,

Aamir



Re: .NET Base Class Library RPC server Unavailable

micvos

I haven't read all your code, but the error message seems to suggest that the RPC service is not running or the connection string is not valid(wrong machine name or something like that).




Re: .NET Base Class Library RPC server Unavailable

AamirKhurshid

Thanks micvos

Machine name is ok ...Coz first i get all the machines on LAN in list after it i select one of them ....

Any other idea ..or pre requsit that i m missing ..

Remote adminstrationis enable ..because i can connect simply for getting the machine name and IP address bt wen i use above conncetion properties then i will get That Exception .....

Any other Idea ..

Thanks for ur KInd Co operation...

Regards,

Aamir





Re: .NET Base Class Library RPC server Unavailable

AamirKhurshid

hmm more clerifying


when code is like this
ConnectionOptions connection = new ConnectionOptions();
connection.Authority = "kerberos:" + domain + @"\" + machine;
//connection.Authority = "NTLMdomain:" + domain;
i m geeting Exception ..
Bt wen i Cooments the line connection.Authority = "kerberos:" + domain + @"\" + machine;
and uncoments line connection.Authority = "NTLMdomain:" + domain;
Then its ok bt its nt meet the requirement ..

An Idea ..
Regards,
Aamir