Perl 使用 Win32::Process 创建进程

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/perl -w

use Win32;
use Win32::Process;

$ApplicationName = 'c:\\winnt\\system32\\notepad.exe';
$CommandLine     = 'notepad';

$CreateOptions = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS;
Win32::Process::Create($ProcessObj,$ApplicationName,$CommandLine,
    0, # Don't inherit.
    $CreateOptions,
    ".")   # current dir.
    or die print_error();

$ProcessObj->Wait(INFINITE) or warn print_error();

$ProcessObj->GetExitCode($ExitCode) or warn print_error();

print "[$CommandLine] exited with $ExitCode\n";

sub print_error {
    print Win32::FormatMessage( Win32::GetLastError() );
}