Skip to content

Instantly share code, notes, and snippets.

@andyburke
Created February 15, 2023 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyburke/b72f8e0c252693e4bc6c7da654cedf7b to your computer and use it in GitHub Desktop.
Save andyburke/b72f8e0c252693e4bc6c7da654cedf7b to your computer and use it in GitHub Desktop.
this is the batch file I use to spin up my flightsim setup. near the top is some explanation. you should be able to change the list of desired programs fairly straightforwardly.
REM enabledelayedexpansion allows variable reuse in the loops below
setlocal enabledelayedexpansion
@echo off
REM loop over a list of programs defined in strings as:
REM
REM <program path>[|<cwd>[|<override command>]]
REM
REM program path - the path to program you want to run
REM cwd - optional working directory to set for the program
REM override command - optional alternate command to run, in this case - launch through steam
REM
REM for each program definition
REM split the string to get the program, directory and command
REM get the executable name to check tasklist for
REM check if the program is already running
REM if it is
REM skip it
REM else
REM start the program
for %%i in (
"C:\Program Files\MSFS2020 Map Enhancement\MSFS2020 Map Enhancement.exe|%USERPROFILE%"
"%USERPROFILE%\Desktop\aitrack-v0.7.1\AITrack.exe|%USERPROFILE%\Desktop\aitrack-v0.7.1\"
"C:\Program Files (x86)\opentrack\opentrack.exe"
"%AppData%\Microsoft Flight Simulator\Packages\Community\fsltl-traffic-injector\fsltl-trafficinjector.exe"
"C:\Program Files (x86)\Steam\steamapps\common\MicrosoftFlightSimulator\FlightSimulator.exe|%USERPROFILE%|steam://rungameid/1250410"
) do (
set infostring=%%i
for /f "tokens=1,2,3 delims=|" %%a in ( !infostring! ) do (
set program=%%a
set directory=%%b
set command=%%c
)
if not defined directory ( set directory=%USERPROFILE% )
if not defined command ( set command=!program! )
for %%f in ( !program! ) do set imagename=%%~nxf
set is_running=
for /f "tokens=5 delims=," %%a in ('
tasklist /fi "imagename eq !imagename!" /fo:csv /nh
') do set is_running=1
if defined is_running (
echo !imagename! - skipping [already running]
) else (
echo !imagename! - starting
echo program: !program!
echo directory: !directory!
echo command: !command!
start "" /d "!directory!" "!command!"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment