; Compile to EXE with encryption to save password ; Utility code that restarts TWS after it gets killed during daily logout USER := "edemo" PASS := "demouser" TWS_DIR := "C:\Jts\952" TWSPath := "C:\Jts\952\tws.exe" Loop { SetTitleMatchMode RegEx If (!WinExist("IB Trader Workstation")) and (!WinExist("Interactive Brokers")) { SetTitleMatchMode 3 IfWinNotExist, Login { Run, %TWSPath% %Args% username=%USER% password=%PASS%, %TWS_DIR% } else { SetTitleMatchMode RegEx WinClose, Login Run, %TWSPath% %Args% username=%USER% password=%PASS%, %TWS_DIR% } } ; check every 2 minutes Sleep 120000 }