# SCRIPT TO START NOTEPAD.EXE #!/usr/bin/perl -w use Win32; use Win32::Process; $ApplicationName = 'c:\\windows\\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->Wait(500) 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() ); } $pid = $ProcessObj->GetProcessID(); print "PID: $pid\n\n"; > PID: 3052 > #### # SCRIPT TO CHECK RUNNING PROCESS #!/usr/bin/perl -w use Win32; use Win32::Process; $pid = shift; Win32::Process::Open($ProcessObj,$pid,1); $ProcessObj->Wait(INFINITE) or warn print_error(); print "END \n"; $ProcessObj->GetExitCode($ExitCode) or warn print_error(); print "...exited with $ExitCode\n"; sub print_error { print Win32::FormatMessage( Win32::GetLastError() ); } #### >PID: 3052 > >Access is denied. > >END >...exited with 259