The Win32::Spawn function acts much like the system function and the Windows start command. : Win32 « Win32 « Perl






The Win32::Spawn function acts much like the system function and the Windows start command.

  

#Win32::Spawn( $ApplicationName,$CommandLine,$ProcessId);
          
#$CommandLine holds the command line to run.this value could be "notepad" or "notepad your.pl". 
#$ProcessId value is set to the Windows ID of the process that gets launched. 
#Win32::Spawn function returns 1 on success and 0 on failure. 



#!/usr/bin/perl -w
use Win32;

#$ApplicationName = 'c:/winnt/system32/notepad.exe';
#$ApplicationName = "C:\\WINDOWS\\NOTEPAD.EXE";
$ApplicationName = 'c:\winnt\system32\notepad.exe';

#$CommandLine = "notepad";
$CommandLine = "notepad spawn.pl";


$status = Win32::Spawn( $ApplicationName,$CommandLine,$ProcessId );

if ( $status != 0 ) {
    print "Launched process with ID $ProcessId.\n";
} else {
    print "Failed to launch process.\n";
}

   
    
  








Related examples in the same category

1.Is windows 95
2.Is windows NT
3.OS version
4.Gets user login name on Windows
5.Node and domain information
6.Convert a Windows-specific error to a text string using the Win32::FormatMessage function.