Making a remote process visible

M

Mark Elley

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";
}
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top