Thank all of you for advice. Win32::Process::Open seem to be very promissing, only that I do some mistake. I have writen 2 short scripts:

# 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 >

*******************************************************************************

The PID I get from the running process I pass to the second script:

# 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() ); }

----------------------------------------------------------------------------------

Unfortunately I get this message:

>PID: 3052 > >Access is denied. > >END >...exited with 259

*******************************************************************************

Have you any idea why I keep getting the massage: Access is denied?

I was thinking about windows services as afoken has suggested as well. I need to start about 20000 processes in about 12 hours with about 100 types of command lines - perl scripts, BAT scripts, executables. Some of them run few seconds, some of them run few hours. Is stil this type of tasks suitable to run via Win32::Daemon?

Thanks

Tomas


In reply to Re: Use another script to check bacground process by Anonymous Monk
in thread Use another script to check bacground process by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.