[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

MS

7/2/2004 12:56:00 PM

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.Create 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:



RemotingConfiguration.Configure( "rpcserver.exe.config" );

TcpServerChannel channel = new TcpServerChannel(rs.mPort);

ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(

typeof(RemoteServerObject),

"ToolCommand",

WellKnownObjectMode.SingleCall);





Code for Client:



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

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

object[] param = {"c:\\temp\\rpcserver.exe",null,null,null};

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

}


2 Answers

Nick Malik

7/2/2004 2:25:00 PM

0

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@discussions.com> wrote in message
news:%23h5o0PDYEHA.3476@tk2msftngp13.phx.gbl...
> 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.Create 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:
>
>
>
> RemotingConfiguration.Configure( "rpcserver.exe.config" );
>
> TcpServerChannel channel = new TcpServerChannel(rs.mPort);
>
> ChannelServices.RegisterChannel(channel);
>
> RemotingConfiguration.RegisterWellKnownServiceType(
>
> typeof(RemoteServerObject),
>
> "ToolCommand",
>
> WellKnownObjectMode.SingleCall);
>
>
>
>
>
> Code for Client:
>
>
>
> ManagementScope obScope = new ManagementScope("\\\\" + remoteServer +
> "\\root\\CIMV2");
>
> ManagementClass shareClass = new ManagementClass( "\\\\" + remoteServer +
> "\\root\\CIMV2:Win32_Process" );
>
> object[] param = {"c:\\temp\\rpcserver.exe",null,null,null};
>
> object response = shareClass.InvokeMethod( "Create", param );
>
> }
>
>


Sunny

7/2/2004 3:24:00 PM

0

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.3476@tk2msftngp13.phx.gbl>,
anonymous@discussions.com says...
> 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.Create 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:
>
>
>
> RemotingConfiguration.Configure( "rpcserver.exe.config" );
>
> TcpServerChannel channel = new TcpServerChannel(rs.mPort);
>
> ChannelServices.RegisterChannel(channel);
>
> RemotingConfiguration.RegisterWellKnownServiceType(
>
> typeof(RemoteServerObject),
>
> "ToolCommand",
>
> WellKnownObjectMode.SingleCall);
>
>
>
>
>
> Code for Client:
>
>
>
> ManagementScope obScope = new ManagementScope("\\\\" + remoteServer +
> "\\root\\CIMV2");
>
> ManagementClass shareClass = new ManagementClass( "\\\\" + remoteServer +
> "\\root\\CIMV2:Win32_Process" );
>
> object[] param = {"c:\\temp\\rpcserver.exe",null,null,null};
>
> object response = shareClass.InvokeMethod( "Create", param );
>
> }
>
>
>