#  Spawning.pl
#  Example 7.9:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script illustrates using the Win32::Spawn() function. It also
#  expands evironment variables using Win32::ExpandEnvronmentStrings().
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


use Win32;
my $App = "%SystemRoot%\\notepad.exe";
my $Args = "notepad %temp%\\test.txt";
$App = Win32::ExpandEnvironmentStrings( $App );
$Args = Win32::ExpandEnvironmentStrings( $Args );
if( Win32::Spawn( $App, $Args, $Pid ) )
{
    print "$App was successfully created with PID $Pid\n";
}
