use strict; use Win32; use Win32::Process; sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } my $ProcessObj1; my $ProcessObj2; Win32::Process::Create($ProcessObj1, $ENV{SystemRoot}."\\explorer.exe", "explorer.exe D:\\", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); Win32::Process::Create($ProcessObj2, $ENV{SystemRoot}."\\notepad.exe", "notepad.exe C:\\test.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); sleep 5; $ProcessObj1->Kill(0) or &ErrorReport; $ProcessObj2->Kill(0) or &ErrorReport; sleep 1; my $pid = $ProcessObj1->GetProcessID(); system('taskkill','/PID',$pid); print "pid:$pid\n";