Start remote app visible

D

Dan Pavel

Hi, I am starting a new process (Notepad) on a remote machine but it is
not visible. When I start it on my machine it is visible. What I am
doing wrong ?

private void run_notepad(string machina)
{
ManagementOperationObserver observer = new
ManagementOperationObserver();
completionHandler.MyHandler completionHandlerObj = new
completionHandler.MyHandler();
observer.ObjectReady += new
ObjectReadyEventHandler(completionHandlerObj.Done);

string stringMachineName;
string stringCommandLine;
stringCommandLine="c:\\winnt\\notepad.exe";
//Connect to the remote computer
ConnectionOptions co = new ConnectionOptions();
stringMachineName = machina;
//get user and password
if (machina!="")
{
co.Username = "aaa";
co.Password = "******";
}
//Point to machine
System.Management.ManagementScope ms = new
System.Management.ManagementScope("\\\\" + stringMachineName +
"\\root\\cimv2", co);
//get process path
ManagementPath path = new ManagementPath( "Win32_Process");
//Get the object on which the method will be invoked
ManagementClass processClass = new ManagementClass(ms,path,null);
//Create an array containing all arguments for the method
object[] methodArgs = {stringCommandLine, null, null, 0};
//Execute the method
processClass.InvokeMethod (observer, "Create", methodArgs);


Thank you
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

My guess is that when you run notepad on the other machine, it is
running in a different desktop session, and not the session that you are
logged into.

You would have to find some way to access that desktop session, and make
the process show up in that.

Hope this helps.
 
W

Willy Denoyette [MVP]

Dan Pavel said:
Hi, I am starting a new process (Notepad) on a remote machine but it is
not visible. When I start it on my machine it is visible. What I am
doing wrong ?

private void run_notepad(string machina)
{
ManagementOperationObserver observer = new
ManagementOperationObserver();
completionHandler.MyHandler completionHandlerObj = new
completionHandler.MyHandler();
observer.ObjectReady += new
ObjectReadyEventHandler(completionHandlerObj.Done);

string stringMachineName;
string stringCommandLine;
stringCommandLine="c:\\winnt\\notepad.exe";
//Connect to the remote computer
ConnectionOptions co = new ConnectionOptions();
stringMachineName = machina;
//get user and password
if (machina!="")
{
co.Username = "aaa";
co.Password = "******";
}
//Point to machine
System.Management.ManagementScope ms = new
System.Management.ManagementScope("\\\\" + stringMachineName +
"\\root\\cimv2", co);
//get process path
ManagementPath path = new ManagementPath( "Win32_Process");
//Get the object on which the method will be invoked
ManagementClass processClass = new ManagementClass(ms,path,null);
//Create an array containing all arguments for the method
object[] methodArgs = {stringCommandLine, null, null, 0};
//Execute the method
processClass.InvokeMethod (observer, "Create", methodArgs);


Thank you

You can't do this. The security system in windows does not allow WMI to
lauch a program that accesses the interactive desktop (if any). I'm not
clear on why you would run a program with his UI on a remote server?

Willy.
 
D

Dan Pavel

Hi, I am trying to uninstall an application remotely. I made an
application who use the uninstall string from the registry of the remote
computer and run it. I used the notepad only to test how can I run a app
remotely on the screen. What I really want to know is if I start the
uninstall how can I pass the confirmation steps (next, finish buttons
for e.g.)

Thank you
 
Q

QWERTY

You can always write a server application then your client could call
that server then the server would execute whatever you want. Since the
server run in the current user session then it should show up on the
screen.
 
W

Willy Denoyette [MVP]

Dan Pavel said:
Hi, I am trying to uninstall an application remotely. I made an
application who use the uninstall string from the registry of the remote
computer and run it. I used the notepad only to test how can I run a app
remotely on the screen. What I really want to know is if I start the
uninstall how can I pass the confirmation steps (next, finish buttons
for e.g.)

Thank you

Why not use sysinternals psexec tool for this? This tool executes a command
on a remote box while redirecting the UI to the client.

http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top