in reply to Show a msgbox and do not wait (Win32)

What is wrong with fork?

use Win32; my $pid = fork(); die "Could not fork Fork!" unless defined $pid; if ( $pid ) { # Parent makes whoopee while kids are away do {print $come_to_momma_honey++ . "\n"; sleep 1 } while 1; } else { # kid so do the MsgBox Win32::MsgBox("My parent's are getting up to mischief while I am w +aiting for you to press OK!"); die "You killed me. Your own flesh and blood!\n"; }

I am on Win2K and this works fine. The count goes on while the message box waits. Parent continues after you press OK while the kid exits. See some other fork examples at My children are driving me crazy Forked off! and Forked up with a bit of explanation.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Show a msgbox and do not wait (Win32)
by Jenda (Abbot) on Feb 19, 2003 at 00:36 UTC

    fork() could be a solution if I were running a Unix. I said I need the script to be able to exit even though the message still sits on the screen. And since fork() creates threads, not processes this will not work. Even if the main thread would end the whole processes will still be alive and the program that started it will wait.

    Jenda

      Fair enough

      cheers

      tachyon

      s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Here is one way that appears to fulfill your requirements.

      use Win32::Process; my $user = $ENV{USERNAME}; my $message = "$0 has a message for $user"; send_message($message); sub send_message { my ($message) = @_; my $Process; my $program = 'C:/WINNT/system32/net.exe'; Win32::Process::Create($Process, "$program", "net send $user $message", 0, DETACHED_PROCESS, ".") or die "Create: $!"; }

      --
      Regards,
      Helgi Briem
      helgi AT decode DOT is