Sometimes dreams come true

I was reading through a thread in the forums that started with "I had a dream about trainz" and many of the posters had a dream similar to "...that the trainz database would not corrupt itself..."

I had posted some years ago a workaround so that this would not happen. Obviously its time for a re-posting. I have tested this on everything up to widows 7 but nothing newer then that. Take a look at this vbs script.

Code:
Option Explicit 
'On Error Resume Next
dim strComputer
dim wmiNS
dim wmiQuery
dim objWMIService
dim colItems
dim objItem
dim found
dim flag
dim mySHell


strComputer = "."
wmiNS = "\root\cimv2"
found = TRUE

Set myShell = WScript.CreateObject("WScript.Shell")
while found
    flag = false
    wmiQuery = "Select processID, name from win32_Process where processID <> 0"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & wmiNS)
    Set colItems = objWMIService.ExecQuery(wmiQuery)
    For Each objItem in colItems
       if objItem.Name = "TADDaemon.exe" Then        
        flag = true
       End If
    Next
    if flag = false Then
        found = false
    end if
wend
'The following line has to be changed to match where your game is installed.
'This example if for 2012 but it will also work with TANE
myShell.run """C:\Program Files (x86)\N3V Games\TS12\Trainz.exe"""

Cut and paste this code into a text file. Save the text file with a .vbs extension. Make sure that the last line of code is the correct path the your trainz.exe file
Be sure not to remove the tripple quotes from the last line as vbs needs this to follow the path correctly.

Lastly follow these rules.

  • Always always always launch the game via this script.
  • Never launch from content manager into the game via the launch game menu feature. Close the program out and run the script.
  • Only as a last resort should you ever shut down taddaemon.exe with the task manager. If you wait long enough the daemon will shutdown.


The script enters into a loop where it checks if the taddaemon.exe is running or not and continues to do this until taddaemon is gone. Then and only then it will start the trainz launcher. As soon as you pick either to launch the game or to launch content manager the vbs scripting engine will shut down.

Heres what I think is up. There is something up with with the taddaemon where if you use the program like most people do eventually you will trigger an event where there are two taddaemons running on your system at the same time. IE Your in the game close it and decide... ok I didn't want to do that yet and go right back in. Or if your in CMP and close it to go into the game. There are lots of situations like this where two copies of that taddaemon.exe are running and wala, the database has to do a repair the next time you launch.

This script is just a hassle free way of making sure that you dont relaunch the game until there isnt another copy of the daemon running. I have used ever since 2006 was released and have not had issues. Which will be my segway into my last suggestion. If you do use this script and you do follows the simple rules I have outlined and your database still gets corrupted then you should look into that, something else is probably going on.

Happy trainzing, Hal
 
Back
Top