Disable TWS automatic Logoff

Method described below is deprecated.  It is recommended to checkout TWS version >= 978 which allows to set a restart time. Login is just required once per week. (Nov. 26, 2019)


this is a quick tutorial how to prevent Interactive Brokers Traders Workstation (TWS) from automatic logoff. It also allows TWS to be started with a double click on a batch (Windows)- or shell (Linux) file.

This tutorial refers to Windows. On Linux just edit .sh files instead of .bat files.Steps to create automatic startup and autologoff preventions are:

  1. Download free open source IBController
  2. Unzip IBController into a folder of your choice
  3. For each TWS login, create a subfolder below IBController folder
  4. Copy files IBController/IBController.ini and IBController/IBControllerStart.bat (.sh on Linux) to this subfolder
  5. Edit IBController.ini to set login name and password and to set a flag to prevent autlogoff
  6. Edit IBControllerStart.bat to set TWS-Version and path to your IBController.ini
  7. Test it


We tested auto startup with TWS 952, TWS 964 and IBController 3.2.0. Before you start, make sure to have a TWS >= version 952 installed. You can check this,  by looking in folder.
c:\jts. You should see something like c:\jts\952 or c:\jts\959

1– Download IBController

Visit Github to get the latest stable version. In this case, it is version 3.2.0. Scroll down to file IBController-3.2.0.zip.

2– Unzip IBController

to C:\IBController. So in C:\IBController you can see  files: README.txt, version, userguide.pdf, etc…

3– Create configuration subfolder

for all your configurations (different IB logins (paper, real) and/or TWS startup), let’s call it: configs. So you finally have a folder


Now in this folder, create a subfolder for a specific configuration. In our case, this is to start TWS version 952 with the public demo login credentials.
Create folder:


and create another folder in this subfolder, call it TWS. (This is used by TWS to store some setup.)



4–Copy files

C:\IBcontroller\IBController.ini and c:\IBController\IBControllerStart.bat to config folder


Also copy [ddownload id="1405" text="our jts.ini default file"] into this config folder.

5–Edit INI file

Scroll to attribute

and set the username of your account. In this case with public demo user:

Scroll to attribute

and set the password to the password of your login. This case the password for public demo:

(You could also set an encryped password...)

To encrypt your password in this file. BUT then, you need to put the encrypted password for IbPassword parameter.

To encrypt password, open file c:\IBController\IBControllerEncrypt.bat and follow instructions. (replace ‘deomuser’ by your password,
run file in a cmd window, copy encrypted password and put behind IbPassword=.

Define the folder, where TWS is storing settings and logfiles. Use the TWS subfolder for this as argument for
attribute IbDir.

     IbDir= c:\IBController\configs\demo_952\TWS

Set the trading mode flag. For livetrading to live , for paper trading to paper. So real accounts should have this set to live. Paper accounts to paper.


Finally, set the attrib IbAutoClosedown to no. This prevents TWS from autologoff.



6– Edit BAT file

Set parameter TWS_MAJOR_VRSN to a version which is installed in c:\jts. In this case 952.


Set the path of the file IBController.ini.



7– Test it

Doubleclick on file c:\IBController\configs\demo_952\IBControllerStart.bat.. This should start TWS, do an automatic login and prevent

TWS from automatic logoff. To test this feature, in TWS open Settings/Lock and Exit

and set the time 5 Minutes to future. !Close this dialog and settings. Wait for logoff time. TWS should NOT be closed. If you reopen logsettings, you will see logoff time shifted.


Hopefully this tutorial can help you to run TWS more convenient and to stop it from logoff. The setup in this tutorial slightly differs from what the IBController makes recommend.
Basically, the recommend to store the config files in the users document folder and to set this folder for encryption. Of course you can do it this way. Just follow the guid, which can
be found in folder






One thought on “Disable TWS automatic Logoff”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.