Help in remoting !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MS

    #1

    Help in remoting !

    In my project I want to execute some commands on the remote machine. I am
    using .Net Remoting to achieve this. My server which is an exe is copied on
    the remote machine and it receives command from client which is executed by
    the exe. I am facing problem while executing the exe on the remote machine.
    If I start the exe manually everything works fine but if I execute it
    remotely through code using WMI an exception is thrown saying "No connection
    could be made because the target machine actively refused it". This
    exception is generally thrown when the remote server is not running but the
    task manager of the remote machine shows that the exe is running. I am
    using Win32_process class to do this. The MSDN help of Win32_process class
    Create() method says "For security reasons the Win32_Process.C reate method
    cannot be used to start an interactive process". Is this the reason for the
    exception? If so, then what is the alternative for executing an exe on
    remote machine?



    I am pasting the code snippet of my client and server below



    Code of Server:



    RemotingConfigu ration.Configur e( "rpcserver.exe. config" );

    TcpServerChanne l channel = new TcpServerChanne l(rs.mPort);

    ChannelServices .RegisterChanne l(channel);

    RemotingConfigu ration.Register WellKnownServic eType(

    typeof(RemoteSe rverObject),

    "ToolComman d",

    WellKnownObject Mode.SingleCall );





    Code for Client:



    ManagementScope obScope = new ManagementScope ("\\\\" + remoteServer +
    "\\root\\CIMV2" );

    ManagementClass shareClass = new ManagementClass ( "\\\\" + remoteServer +
    "\\root\\CIMV2: Win32_Process" );

    object[] param = {"c:\\temp\\rpc server.exe",nul l,null,null};

    object response = shareClass.Invo keMethod( "Create", param );

    }


  • Nick Malik

    #2
    Re: Help in remoting !

    The error you are getting sounds like your server app is an interactive
    application. Is this true? (Doesn't make sense to me).

    I'd assume that your server would be implemented as a windows service or
    started by a windows service. Is this the case?

    ? confused ?
    --- Nick

    "MS" <anonymous@disc ussions.com> wrote in message
    news:%23h5o0PDY EHA.3476@tk2msf tngp13.phx.gbl. ..[color=blue]
    > In my project I want to execute some commands on the remote machine. I am
    > using .Net Remoting to achieve this. My server which is an exe is copied[/color]
    on[color=blue]
    > the remote machine and it receives command from client which is executed[/color]
    by[color=blue]
    > the exe. I am facing problem while executing the exe on the remote[/color]
    machine.[color=blue]
    > If I start the exe manually everything works fine but if I execute it
    > remotely through code using WMI an exception is thrown saying "No[/color]
    connection[color=blue]
    > could be made because the target machine actively refused it". This
    > exception is generally thrown when the remote server is not running but[/color]
    the[color=blue]
    > task manager of the remote machine shows that the exe is running. I am
    > using Win32_process class to do this. The MSDN help of Win32_process class
    > Create() method says "For security reasons the Win32_Process.C reate method
    > cannot be used to start an interactive process". Is this the reason for[/color]
    the[color=blue]
    > exception? If so, then what is the alternative for executing an exe on
    > remote machine?
    >
    >
    >
    > I am pasting the code snippet of my client and server below
    >
    >
    >
    > Code of Server:
    >
    >
    >
    > RemotingConfigu ration.Configur e( "rpcserver.exe. config" );
    >
    > TcpServerChanne l channel = new TcpServerChanne l(rs.mPort);
    >
    > ChannelServices .RegisterChanne l(channel);
    >
    > RemotingConfigu ration.Register WellKnownServic eType(
    >
    > typeof(RemoteSe rverObject),
    >
    > "ToolComman d",
    >
    > WellKnownObject Mode.SingleCall );
    >
    >
    >
    >
    >
    > Code for Client:
    >
    >
    >
    > ManagementScope obScope = new ManagementScope ("\\\\" + remoteServer +
    > "\\root\\CIMV2" );
    >
    > ManagementClass shareClass = new ManagementClass ( "\\\\" + remoteServer +
    > "\\root\\CIMV2: Win32_Process" );
    >
    > object[] param = {"c:\\temp\\rpc server.exe",nul l,null,null};
    >
    > object response = shareClass.Invo keMethod( "Create", param );
    >
    > }
    >
    >[/color]


    Comment

    • Sunny

      #3
      Re: Help in remoting !

      Hi,

      can you put all channel and object registration code in try/catch block,
      and make a logging in a local text file for every step performed and
      possible exceptions?

      Sunny


      In article <#h5o0PDYEHA.34 76@tk2msftngp13 .phx.gbl>,
      anonymous@discu ssions.com says...[color=blue]
      > In my project I want to execute some commands on the remote machine. I am
      > using .Net Remoting to achieve this. My server which is an exe is copied on
      > the remote machine and it receives command from client which is executed by
      > the exe. I am facing problem while executing the exe on the remote machine.
      > If I start the exe manually everything works fine but if I execute it
      > remotely through code using WMI an exception is thrown saying "No connection
      > could be made because the target machine actively refused it". This
      > exception is generally thrown when the remote server is not running but the
      > task manager of the remote machine shows that the exe is running. I am
      > using Win32_process class to do this. The MSDN help of Win32_process class
      > Create() method says "For security reasons the Win32_Process.C reate method
      > cannot be used to start an interactive process". Is this the reason for the
      > exception? If so, then what is the alternative for executing an exe on
      > remote machine?
      >
      >
      >
      > I am pasting the code snippet of my client and server below
      >
      >
      >
      > Code of Server:
      >
      >
      >
      > RemotingConfigu ration.Configur e( "rpcserver.exe. config" );
      >
      > TcpServerChanne l channel = new TcpServerChanne l(rs.mPort);
      >
      > ChannelServices .RegisterChanne l(channel);
      >
      > RemotingConfigu ration.Register WellKnownServic eType(
      >
      > typeof(RemoteSe rverObject),
      >
      > "ToolComman d",
      >
      > WellKnownObject Mode.SingleCall );
      >
      >
      >
      >
      >
      > Code for Client:
      >
      >
      >
      > ManagementScope obScope = new ManagementScope ("\\\\" + remoteServer +
      > "\\root\\CIMV2" );
      >
      > ManagementClass shareClass = new ManagementClass ( "\\\\" + remoteServer +
      > "\\root\\CIMV2: Win32_Process" );
      >
      > object[] param = {"c:\\temp\\rpc server.exe",nul l,null,null};
      >
      > object response = shareClass.Invo keMethod( "Create", param );
      >
      > }
      >
      >
      >[/color]

      Comment

      Working...