Panda_DCS Posted August 27, 2020 Posted August 27, 2020 I am trying to run a windows bat file when the simulation quits. I have been able to run the bat file through a Hook using function callbacks.onSimulationStop() But that runs when the mission is stopped and when the simulation quits. I only want it to fire when the simulation quits similar to LuaExportStop(). For some reason I have been unable to get this to work using LuaExportStop() even though I have been able to execute other code this way. I thought you could call Export.LuaExportStop() from inside a Hook, but that isn't working either. I would be very appreciative if anyone could point me in the right direction for running this Bat file when the simulation quits. Thanks Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
metalnwood Posted August 28, 2020 Posted August 28, 2020 (edited) Why dont you just add dcs.exe to the first line of your bat file and use that to start dcs and then run our commands afterwards? edit, i may be reading this wrong? you want to run it when a simulation ends and takes you to the end of mission screen not when the dcs process is about to end? So you have added your call to run the batch file in to the LuaExportStop but it is not running? Edited August 28, 2020 by metalnwood
Panda_DCS Posted August 28, 2020 Author Posted August 28, 2020 I want the bat file to run when the DCS process ends. Basically the server restarts at a certain interval and when the server process stops I want this bat file to execute. The only way I knew to make this happen was to call the bat file from the LuaExportStop function because to my knowledge that was only called when you right clicked and closed the server window. If there is another way I am open to suggestions...I am not that familiar with bat files but if I can do this in the bat file I would give it a shot. Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
metalnwood Posted August 29, 2020 Posted August 29, 2020 OK, so when the dcs process ends is when you quit to desktop. You then want to run abc.bat You will see that when you look at the properties of the dcs icon it is something like d:\dcsword\bin\dcs.exe update - somehting like this, I am not in front of computer to see that exactly. I would take that and add it as the first line of your batch file. Then run your batch file whenever you want to run DCS. your batch file will run dcs and then whatever else is in it when DCS finishes. You can still create a desktop icon or menu item to run your batch file to make it convenient.
Panda_DCS Posted August 29, 2020 Author Posted August 29, 2020 Thanks. I did not know that. I will give it a try. Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
Panda_DCS Posted September 1, 2020 Author Posted September 1, 2020 I am having issues getting this to work. I have tried several different combination using Start, call, and /wait but nothing has worked. Here is my base code. Launched both DCS and script simultaneously rem @echo off "H:\DCS WORLD Dedicated Server\DCS World OpenBeta Server\bin\DCS_updater.exe" "C:\Python38\python.exe" "H:\CODE\pythonScripts\stack-working.py" Same as above rem @echo off START "" "H:\DCS WORLD Dedicated Server\DCS World OpenBeta Server\bin\DCS_updater.exe" "C:\Python38\python.exe" "H:\CODE\pythonScripts\stack-working.py" Same as above rem @echo off START /wait "" "H:\DCS WORLD Dedicated Server\DCS World OpenBeta Server\bin\DCS_updater.exe" "C:\Python38\python.exe" "H:\CODE\pythonScripts\stack-working.py" Any suggestions appreciated. Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
metalnwood Posted September 1, 2020 Posted September 1, 2020 Ah.. ok.. Change the dcs_updater.exe to just dcs.exe. Do it in your first example, not the ones using START. The updater will start the DCS process after it has checked for updates but then quits right away making your python script run. If you change to dcs.exe it wont check for updates and you will have to run the updater yourself from time to time.
Panda_DCS Posted September 2, 2020 Author Posted September 2, 2020 Unfortunately that doesn't work. When I run the dcs.exe directly dcs asks for serial numbers to all the terrains...which you should not need for the dedicated server...and then it crashes. When running DCS_updater.exe which is the executable it installed by default it starts right up. On the bright side when it crashed it did then run the batch file as desired, but obviously not starting is a problem. Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
metalnwood Posted September 2, 2020 Posted September 2, 2020 (edited) That is strange, I am not sure whats happening there except perhaps it has not worked out what directory it is in. add these lines ahead of it. This will change the working directory to the correct one before running dcs which could be the issue. h: cd "H:\DCS WORLD Dedicated Server\DCS World OpenBeta Server\bin" oh and just rad that if you are running a server you should have the parameter --server.. i.e. dcs.exe --server Edited September 2, 2020 by metalnwood
Panda_DCS Posted September 3, 2020 Author Posted September 3, 2020 So I was able to get the result I want by making the following bat file @echo off rem restart every 4 hours (14400 seconds) :loop start "" "PATH TO DCS LAUNCHER" timeout /t 14400 taskkill /im dcs.exe /f timeout /t 20 "PATH TO PYTHON EXE" "PATH TO PYTHON SCRIPT" goto loop Sim Rig: Intel i7 9700k, SSD, GTX1660Ti, 32 GB DDR4, Windows 10 HOTAS: TM Warthog, MFG Crosswind Pedals, Opentrack - DIY HeadTracker IRL: Private Pilot - IFR, Part 107 Drone Pilot
Recommended Posts