470,594 Members | 1,468 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

Making a remote process visible

I am using the following code to start a process on a networked XP
machine. This all works really well but the process created is
invisible to the user (only visible in the Task Manager - Processes
tab). I need this process to be visible. I have searched for the
answers but have come to the conclusion that it is either a)
impossible or b) it is so easy that it is not documented !!!

Usage: perl filename.pl exe_to_run.exe

use Win32::OLE qw( in );
use Win32::OLE::Variant;

$Machine = "10.141.9.73";

$CLASS = "WinMgmts:{impersonationLevel=impersonate}!//$Machine";

$WMI = Win32::OLE-> GetObject( $CLASS ) || die "Unable to connect to
$Machine:" . Win32::OLE->lastError();

$PROCESSSTARTUP = $WMI-> Get("Win32_ProcessStartup")->SpawnInstance_;

$PROCESSSTARTUP-> {WinstationDesktop} = "winsta0\\default";

$PROCESSSTARTUP-> {ShowWindow} = 1;

print "$PROCESSSTARTUP-> {WinstationDesktop}\n";

$Process = $WMI-> Get( "Win32_Process" ) || die "Unable to get the
process list:" . Win32::OLE-> LastError();

$vPid = Variant( VT_I4 | VT_BYREF, 0 );

if( 0 == $Process-> Create( join( " ", @ARGV ), undef,
$PROCESSSTARTUP, $vPid ) ) {
print "Process successfully created with PID $vPid\n";
}
else {
print "Failed to create process.\n";
}
Jul 19 '05 #1
0 2244

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nick Bunton | last post: by
2 posts views Thread by Peter | last post: by
3 posts views Thread by Dakkar | last post: by
5 posts views Thread by Dan Pavel | last post: by
1 post views Thread by JLuis Estrada | last post: by
7 posts views Thread by Ctal | last post: by
3 posts views Thread by Billy Bob | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.