my($exitcode,$junk,$process,$process2,$process3); use Win32::Process; #create a notepad process Win32::Process::Create( $process, "c:\\winnt\\system32\\notepad.exe", "", 0, NORMAL_PRIORITY_CLASS, '.', ) or die "Could not start process\n"; #get the processid $procid=$process->GetProcessID(); print "PROCID: $procid\n"; #open the procid and get the exit code if(Win32::Process::Open($process2,$procid,0)==1){ Win32::Process::Open($process2,$procid,0); $exit=$process2->GetExitCode( $exitcode ); print "EXIT for PROCID-$procid: $exit\n"; print "Enter to continue\n"; }else{ print "ProcessID $procid not running\n"; } $junk=; #ok, kill the process $process->Kill( $exitcode ); print "$procid Process Killed\n"; print "Enter to continue\n"; $junk=; #now get the procid and exit code again if(Win32::Process::Open($process3,$procid,0)==1){ Win32::Process::Open($process3,$procid,0); $exit=$process3->GetExitCode( $exitcode ); print "EXIT for PROCID-$procid: $exit\n"; }else{ print "ProcessID $procid not running\n"; } exit;