Batch Files to Open and Close Flight Simulator
/Opening and closing the various files and ancillary programs to operate a flight simulator can be onerous and time consuming. While there have been several programs released that enable you to launch flight simulator with a press of a key, they seldom work with complicated platforms such as flight decks.
One of the most commonly used methods to open files and programs is to use the start menu within Windows. However, this is not without it’s shortcomings, and specialist knowledge is required. An easy and trouble free approach is to use batch files.
What is a Batch File
A batch file is a script file that stores commands to be executed in a sequential order. It helps automate routine tasks without requiring user input or intervention. Some common applications of batch files include loading and closing programs, running multiple processes or performing repetitive sequential actions.
Also known as a batch job, a batch file is a text file created in Notepad or some other text editor. A batch file bundles or packages a set of commands into a single file in serial order. Without a batch file these commands would have to be presented one at a time to the system from a keyboard.
Usually, a batch file is created for command sequences when a user has a repetitive need. A command-line interpreter takes the file as an input and executes the commands in the given order. A batch file eliminates the need to retype commands, which saves the user time and helps to avoid mistakes. It is also useful to simplify complex processes.
Windows usually uses the .bat extension for batch files.
There are many ways to create a batch file, some are very simplistic and others quite complex. Often there are several strings of sytax that can be used to effectively achieve a similar result. The following are examples.
Writing a Batch File
It's a simple process to write a batch file.
Prior to beginning, it’s wise to think about the order you want the programs to open, and whether you want a pause between opening particular files and programs. While a pause is probably not necessary, it’s a good idea as it allows a file or program to complete its opening sequence, prior to the next file or program opening.
When you have completed writing the batch file in notepad save the file with a .bat extension. To test the batch file double click on the saved .bat extension.
Although others may disagree, MSFS2020 or P3d should be run and the program allowed to settle before opening any batch file or other flight simulator related programs.
The following simplistic examples of batch files are user-specific. You will need to substitute the file structure with the file structure you are using.
Opening Files and Programs
1. An example of a simplistic batch file to open the main flight simulator computer (server).
@Echo off
//Alpha Main Server Computer (ALPHA-SERVER-P3) - 09:38 - 25/08/2023
//ProSim738 V3
//ProSim Ancillary Programs
start /d "D:\Flight Simulator Files\SimStacks October 2021\SimStackSwitchv702" Switch.jar
Timeout 1
start /d "D:\Flight Simulator Files\FS Set Volume" FSSetvol.exe
Timeout 1
start /d "D:\Flight Simulator Files\SimSounds 4.0" SimSounds.exe
Timeout 1
start /d "D:\REX WeatherForce.exe
//ProSim Main Programs
start /d "D:\Flight Simulator Files\ProSim738 V3\ProSimAudio" ProsimAudio.exe
Timeout 1
start /d "D:\Flight Simulator Files\ProSim738 V3\ProSimB738" ProSimB738.exe
2. An example of a batch file to open the avionics suite on the second computer (client 1).
@Echo off
//Client 1 - ProSim-AR B738 Avionics Suite V3 14:07 5/09/20
//PS738 V3
//Ancillary Programs
start /d "C:\Users\user name\Documents\FSF\Programs\MSFS WideFS7" kilo
start /d "C:\Users\user name\Documents\FSF\Programs\Landing Rate Monitor" LRM.exe
start /d "C:\Users\user name\Documents\FSF\Programs\SimSounds 4.0" SimSounds.exe
//Hardware Connector
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\ProSimB738-HardwareConnector" ProSimB738-HardwareConnector.exe
//ProSim737 Displays and Indicators
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\CAPT PFD" ProsimDisplay.exe
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\CAPT ND" ProsimDisplay.exe
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\FO PFD" ProsimDisplay.exe
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\FO ND" ProsimDisplay.ex
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\EICAS" ProsimDisplay.exe
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\Displays\FLAPS" ProsimDisplay.exe
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\PS738ChronoCaptain" ProsimDisplay.exe
Timeout 3
start /d "C:\Users\user name\Documents\FSF\ProSim738 V3\ProSimIOS" ProSimIOS.exe
Closing Files and Programs
Likewise, you can also use a batch file to close files and programs sequentially or simultaneously (kill all).
An example of a batch file used to close programs on the main flight simulation computer (server).
@Echo off
//Alpha Main Server Computer (ALPHA-SERVER-P3) - 09:38 - 25/08/2023
//ProSim738 V3 – closure batch
taskkill /IM wideclient.exe
Timeout 2
taskkill /IM ProSimAudio.exe
Timeout 1
taskkill /IM PMSounds.exe
Timeout 1
taskkill /IM Prosim737.exe
Timeout 4
taskkill /IM fs2020.exe
im specifies the image name of the process to be terminated (for example, PMSounds.exe or ProSim737.exe).
@echo is the sytax used to determine if a name or message will be displayed on the console when the batch file is executed. If echo is used by itself it will print whatever follows to the console screen. Echo on/off controls whether the command lines are displayed. The @ sign (as in @echo) located at the beginning of a command line tells the system to not display the command in the console.
The // syntax is used to stop the line from being read by the batch file. Likewise echo and :: can be used.
In the examples, the Taskkill command has been used to close the programs. Taskkill will cause the program to terminate gracefully, asking for confirmation if there are unsaved changes.
To forcefully kill a process, add the /F option to the command line. Be careful with the /F option as it will terminate all matching processes without confirmation (it does not gracefully close a program).
An example using the /F command is: Taskkill /F /IM ProSimAudio.exe.
There is debate in the computer community to the validity of closing files and programs simultaneously, as ‘killing a program’ may not allow the program enough time to save information it may be saving during the closure process.
For this reason, I'm hesitant to close flight simulator (or other programs) using a closure batch file without a timeout or delay sequence. Needless to say, it's an easy process to configure a time delay into a batch file to create a delay before closing each program.
Timeouts
Depending upon your computer specifications, some programs may open and close at differing speeds. If you want a program is open or close before the next program, then a delay sequence will need to be timed into your batch file.
The timeout command is used to trigger a delay between the programs, enabling any read/write requirements to occur prior to the next program beginning it closure routine. There are a number of ways to write timeout command. Timeout 1 will cause a one second pause between each command. Timeout /t 5 will cause a pause of five seconds.
Streamlining
Once you have created and saved the batch file, a suggestion is to create a shortcut to the file. Doing this will enable you to make changes to the batch file such as how the file is executed (minimised or maximised), the position on the screen, colour and font style used (if the script does not already do this), and whether to use an icon for easy identification. Additionally, by creating a shortcut it enables you to place the shortcut on the computer’s taskbar.
To create a shortcut, right click the batch file and save as a shortcut.
Using Batch Files and ProSim IOS
ProSim-TS IOS screen in opened to network page. Rather than explain everything, copy the details and use trial and error to achieve your desired result
If you are using multiple computers, you may want to use the ProSim Instructor Operator Station (IOS) to trigger the opening or closure of programs (via the batch file). When IOS is configured correctly, you will be able to open and close a batch file on one or more networked computers from one computer screen.
To configure IOS, open the network tab, select add a new action or type and select start program. In the path to executable file on client box type the file address of the batch opening file. Choose the start option you prefer and ensure that enabled in checked.
To close your programs, open a second action and type in to the path to executable on client box the file address of the batch closure file.
The accompanying image should be self explanatory.
There are other ways to do this, however, this method is probably the simplest.
Caveat
I am not computer technician. I have used batch files similar to the examples shown for many years without issues.
Final Call
Batch files are but one way to minimise workload and automate the opening and closure of ancillary programs that are used with flight simulator. The use of IOS to trigger batch files also enables the user to open and close ancillary programs from the one computer screen (instructor station).
