Problem:
You want to start an application in a step and keep it running after the step completes. However when you call the application directly (for example, notepad.exe), the step does not complete until the application exits.
Solution:
Use the following code to start the application and set the step shell to “ec-perl”.
use ElectricCommander;
use Win32;
use Win32::Process;
$ApplicationName = 'C:\\Windows\\System32\\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();
print "$ApplicationName is still running.\n";
sub print_error {
print Win32::FormatMessage( Win32::GetLastError() );
}
This example starts notepad.exe and it continues running while the step completes.
Note:
You may need to start the agent in interactive mode if you want to start an application with GUI. Please refer to this article for more details.
Applies To:
All ElectricCommander and CloudBees CD (CloudBees Flow) agents in Windows platform.
0 Comments