Run EXE in Windows using Perl

Source: Internet
Author: User
Tags perl script

The current project has just completed the compilation link of all components, and it is okay to run it.

However, you have to double-click six programs (four window programs and two command line programs) each time you run the program ).

I just want to know if I can perform a batch operation once.

I first thought of the bat script, but because there are two command-line programs, and they are the same type of endless loops that do not exit, this causes the first in BAT to get stuck without running the second one.

I found some information on how to run it in the background on the Internet, all about VB.

Later, I thought Perl should be a piece of cake for this kind of feature. Find it online and find it.

1 system("Client.exe print");

 

The problem is the same as that of BAT.

Later, I opened the Perl help document and saw Win32: process.

Copy the example to run it.

But there are two problems:

1. Both command line programs run in a command window at the same time (same as the problem with BAT)

2. Some window programs can contain parameters but cannot run normally.

 

 1 #!/usr/bin/perl 2  3 use Win32::Process; 4 use Win32; 5 sub ErrorReport{ 6 print Win32::FormatMessage( Win32::GetLastError() ); 7 } 8 Win32::Process::Create($ProcessObj1, "Client.exe", "",  9                     0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();10 sleep(5);11 Win32::Process::Create($ProcessObj2, "GndSystem.exe", "",12                      0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();13 sleep(5);14 Win32::Process::Create($ProcessObj3, "LmiInterface.exe", "",15                      0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();16 sleep(5);17 Win32::Process::Create($ProcessObj4, "Monitor.exe", "",18                      0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport();19 sleep(5);20 #Win32::Process::Create($ProcessObj6, 'C:\Sim.exe', 'PACARS.sim', 0, NORMAL_PRIORITY_CLASS, 'C:\SecureACARS\Database')|| die ErrorReport();21 system('C:\Sim.exe PACARS.sim');

 

A Perl script with an empty log file is attached:

1 #!/usr/bin/perl2 3 open $Log, '> C:\GPAComm.log';4 close $Log;5 open $Log, '> C:\CoreError.log';6 close $Log;7 open $Log, '> C:\GPAError.log';8 close $Log;

http://www.tianming.me/?p=830
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.