-
Notifications
You must be signed in to change notification settings - Fork 181
/
StartIBC.bat
589 lines (508 loc) · 17.8 KB
/
StartIBC.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
@echo off
setlocal enableextensions enabledelayedexpansion
:: Grateful thanks to Rob van der Woude for his wonderful scripting pages website at:
::
:: http://www.robvanderwoude.com/
::
:: It made the excruciating task of batch file authoring considerably less painful!
::
:: Note that this command file is a 'service file' intended to be called from
:: higher level command files. There should be no reason for the end user to modify
:: it in any way. So PLEASE DON'T CHANGE IT UNLESS YOU KNOW WHAT YOU'RE DOING!
if "%1"=="" goto :showUsage
if "%1"=="/?" goto :showUsage
if "%1"=="-?" goto :showUsage
if /I "%1"=="/HELP" goto :showUsage
goto :doIt
:showUsage
::===0=========1=========2=========3=========4=========5=========6=========7=========8
echo.
echo Runs IBC, thus loading TWS or the IB Gateway
echo.
echo Usage:
echo.
echo StartIBC twsVersion [/G ^| /Gateway] [/TwsPath:twsPath]
echo [/TwsSettingsPath:twsSettingsPath] [/IbcPath:ibcPath]
echo [/Config:configfile] [/JavaPath:javaPath]
echo [/User:userId] [/PW:password]
echo [/FIXUser:fixuserId] [/FIXPW:fixpassword]
echo [/Mode:tradingMode]
echo [/On2FATimeout:2fatimeoutaction]
echo.
echo twsVersion The major version number for TWS
echo.
echo /G or /Gateway Indicates that the IB Gateway is to be loaded rather
echo than TWS
echo.
echo twsPath Path to the TWS installation folder. Defaults to
echo %SYSTEMDRIVE%\Jts
echo.
echo twsSettingsPath Path to the TWS settings folder. Defaults to
echo the twsPath argument
echo.
echo ibcPath Path to the IBC installation folder.
echo Defaults to %SYSTEMDRIVE%\IBC
echo.
echo configfile The location and filename of the IBC
echo configuration file. Defaults to
echo ^%%USERPROFILE^%%\Documents\IBC\config.ini
echo.
echo javaPath Path to the folder containing the java.exe to be used
echo to run IBC. Defaults to the java.exe included
echo in the TWS installation; failing that, to the Oracle
echo Java installation
echo.
echo userId IB account user id
echo.
echo password IB account password
echo.
echo fixuserId FIX account user id (only if /G or /Gateway)
echo.
echo fixpassword FIX account password (only if /G or /Gateway)
echo.
echo tradingMode Indicates whether the live account or the paper
echo trading account will be used. Allowed values are:
echo.
echo live
echo paper
echo.
echo These values are not case-sensitive.
echo.
echo 2fatimeoutaction Indicates what to do if IBC exits due to second factor
echo authentication timeout. Allowed values are:
echo
echo restart
echo exit
echo.
exit /B
::===0=========1=========2=========3=========4=========5=========6=========7=========8
:doIt
:: Some constants
set E_NO_JAVA=1001
set E_NO_TWS_VERSION=1002
set E_INVALID_ARG=1003
set E_TWS_VERSION_NOT_INSTALLED=1004
set E_IBC_PATH_NOT_EXIST=1005
set E_CONFIG_NOT_EXIST=1006
set E_TWS_VMOPTIONS_NOT_FOUND=1007
set E_TWS_SETTINGS_PATH_NOT_EXIST=1008
:: errorlevel set by IBC if second factor authentication dialog times out and
:: ExitAfterSecondFactorAuthenticationTimeout setting is true
set E_2FA_DIALOG_TIMED_OUT=1111
:: errorlevel set by IBC if login dialog is not displayed within the time
:: specified in the LoginDialogDisplayTimeout setting
set E_LOGIN_DIALOG_DISPLAY_TIMEOUT=1112
set ENTRY_POINT_TWS=ibcalpha.ibc.IbcTws
set ENTRY_POINT_GATEWAY=ibcalpha.ibc.IbcGateway
:: Variables to be derived from arguments
set TWS_VERSION=
set PROGRAM=TWS
set PROGRAM_PATH=
set ENTRY_POINT=%ENTRY_POINT_TWS%
set TWS_PATH=
set TWS_SETTINGS_PATH=
set IBC_PATH=
set CONFIG=
set JAVA_PATH=
set IB_USER_ID=
set IB_PASSWORD=
set FIX_USER_ID=
set FIX_PASSWORD=
set MODE=
set TWOFA_TO_ACTION=
set ERROR_MESSAGE=
::======================== Parse command line arguments =====================
set PHASE=Parsing command line arguments
:parse
if "%~1" == "" goto :parsingComplete
set ARG=%~1
if /I "%ARG%" == "/G" (
set ENTRY_POINT=%ENTRY_POINT_GATEWAY%
set PROGRAM=Gateway
) else if /I "%ARG%" == "/GATEWAY" (
set ENTRY_POINT=%ENTRY_POINT_GATEWAY%
set PROGRAM=Gateway
) else if /I "%ARG:~0,9%" == "/TWSPATH:" (
set TWS_PATH=%ARG:~9%
) else if /I "%ARG:~0,17%" == "/TWSSETTINGSPATH:" (
set TWS_SETTINGS_PATH=%ARG:~17%
) else if /I "%ARG:~0,9%" == "/IBCPATH:" (
set IBC_PATH=%ARG:~9%
) else if /I "%ARG:~0,8%" == "/CONFIG:" (
set CONFIG=%ARG:~8%
) else if /I "%ARG:~0,10%" == "/JAVAPATH:" (
set JAVA_PATH=%ARG:~10%
if "%JAVA_PATH%" == """" set JAVA_PATH=
) else if /I "%ARG:~0,6%" == "/USER:" (
set IB_USER_ID=%ARG:~6%
) else if /I "%ARG:~0,4%" == "/PW:" (
set IB_PASSWORD=%ARG:~4%
) else if /I "%ARG:~0,9%" == "/FIXUSER:" (
set FIX_USER_ID=%ARG:~9%
) else if /I "%ARG:~0,7%" == "/FIXPW:" (
set FIX_PASSWORD=%ARG:~7%
) else if /I "%ARG:~0,6%" == "/MODE:" (
set MODE=%ARG:~6%
) else if /I "%ARG:~0,14%" == "/ON2FATIMEOUT:" (
set TWOFA_TO_ACTION=%ARG:~14%
) else if /I "%ARG:~0,1%" == "/" (
set ERROR_MESSAGE=Invalid parameter '%ARG%'
set ERROR=%E_INVALID_ARG%
) else if not defined TWS_VERSION (
set TWS_VERSION=%ARG%
) else (
set ERROR_MESSAGE=Invalid parameter '%ARG%'
set ERROR=%E_INVALID_ARG%
)
shift
goto :parse
:parsingComplete
set PHASE=Checking supplied configuration data
if defined IB_USER_ID set GOT_API_CREDENTIALS=1
if defined IB_PASSWORD set GOT_API_CREDENTIALS=1
if defined FIX_USER_ID set GOT_FIX_CREDENTIALS=1
if defined FIX_PASSWORD set GOT_FIX_CREDENTIALS=1
if defined GOT_FIX_CREDENTIALS (
if not "%PROGRAM%" == "GATEWAY" (
set ERROR_MESSAGE=FIX user id and FIX password are only valid for the Gateway
set ERROR=%E_INVALID_ARG%
)
)
if defined MODE (
if /I "%MODE%" == "LIVE" (
echo. > NUL
) else if /I "%MODE%" == "PAPER" (
echo. > NUL
) else (
set ERROR_MESSAGE=Trading mode set to '%MODE%' but must be either 'live' or 'paper'
set ERROR=%E_INVALID_ARG%
)
)
if defined TWOFA_TO_ACTION (
if /I "%TWOFA_TO_ACTION%" == "RESTART" (
echo. > NUL
) else if /I "%TWOFA_TO_ACTION%" == "EXIT" (
echo. > NUL
) else (
set ERROR_MESSAGE=2FA timeout action set to %TWOFA_TO_ACTION% but must be either 'restart' or 'exit'
set ERROR=%E_INVALID_ARG%
)
)
if defined ERROR goto :err
echo.
echo ================================================================================
echo.
echo Starting IBC version %IBC_VRSN% on %DATE% at %TIME%
echo.
for /f "usebackq tokens=* skip=1" %%a in (`wmic OS get Caption^,Version^,OSArchitecture ^| findstr "." `) do echo Operating system: %%a
echo.
:: log the arguments
echo Arguments:
echo.
echo TWS version = %TWS_VERSION%
echo Program = %PROGRAM%
echo Entry point = %ENTRY_POINT%
echo /TwsPath = %TWS_PATH%
echo /TwsSettingsPath = %TWS_SETTINGS_PATH%
echo /IbcPath = %IBC_PATH%
echo /Config = %CONFIG%
echo /Mode = %MODE%
echo /JavaPath = %JAVA_PATH%
if defined GOT_API_CREDENTIALS (
echo /User = ***
echo /PW = ***
) else (
echo /User =
echo /PW =
)
if defined GOT_FIX_CREDENTIALS (
echo /FIXUser = ***
echo /FIXPW = ***
) else (
echo /FIXUser =
echo /FIXPW =
)
echo.
::======================== Check everything ready to proceed ================
if not defined TWS_VERSION (
set ERROR_MESSAGE=TWS major version number has not been supplied
set ERROR=%E_NO_TWS_VERSION%
goto :err
)
if not defined TWS_PATH set TWS_PATH=%SYSTEMDRIVE%\Jts
if not defined TWS_SETTINGS_PATH set TWS_SETTINGS_PATH=%TWS_PATH%
if not defined IBC_PATH set IBC_PATH=%SYSTEMDRIVE%\IBC
if not defined CONFIG set CONFIG=%USERPROFILE%\Documents\IBC\config.ini
set TWS_PROGRAM_PATH=%TWS_PATH%\%TWS_VERSION%
set GATEWAY_PROGRAM_PATH=%TWS_PATH%\ibgateway\%TWS_VERSION%
if "%PROGRAM%" == "TWS" (
set PROGRAM_PATH=%TWS_PROGRAM_PATH%
set ALT_PROGRAM_PATH=%GATEWAY_PROGRAM_PATH%
set VMOPTIONS_SOURCE=!PROGRAM_PATH!\tws.vmoptions
set ALT_VMOPTIONS_SOURCE=!ALT_PROGRAM_PATH!\ibgateway.vmoptions
) else (
set PROGRAM_PATH=%GATEWAY_PROGRAM_PATH%
set ALT_PROGRAM_PATH=%TWS_PROGRAM_PATH%
set VMOPTIONS_SOURCE=!PROGRAM_PATH!\ibgateway.vmoptions
set ALT_VMOPTIONS_SOURCE=!ALT_PROGRAM_PATH!\tws.vmoptions
)
if not exist "%PROGRAM_PATH%\JARS" (
set PROGRAM_PATH=%ALT_PROGRAM_PATH%
set VMOPTIONS_SOURCE=%ALT_VMOPTIONS_SOURCE%
)
set JARS=%PROGRAM_PATH%\jars
set INSTALL4J=%PROGRAM_PATH%\.install4j
if not exist "%JARS%" (
set ERROR_MESSAGE=Offline TWS/Gateway version %TWS_VERSION% is not installed: can't find jars folder
set ERROR_MESSAGE1=Make sure you install the offline version of TWS/Gateway
set ERROR_MESSAGE2=IBC does not work with the auto-updating TWS/Gateway
set ERROR=%E_TWS_VERSION_NOT_INSTALLED%
goto :err
)
if not exist "%TWS_SETTINGS_PATH%" (
set ERROR_MESSAGE=TWS settings path: %TWS_SETTINGS_PATH% does not exist
set ERROR=%E_TWS_SETTINGS_PATH_NOT_EXIST%
goto :err
)
pushd %TWS_SETTINGS_PATH%
:: ensure TWS_SETTINGS_PATH contains no double backslashes: they cause
:: problems when trying to find the autorestart file
set TWS_SETTINGS_PATH=%CD%
popd
if not exist "%IBC_PATH%" (
set ERROR_MESSAGE=IBC path: %IBC-PATH% does not exist
set ERROR=%E_IBC_PATH_NOT_EXIST%
goto :err
)
if not defined CONFIG (
set CONFIG=NULL
) else if not exist "%CONFIG%" (
set ERROR_MESSAGE=IBC configuration file: %CONFIG% does not exist
set ERROR=%E_CONFIG_NOT_EXIST%
goto :err
)
if not exist "%VMOPTIONS_SOURCE%" (
echo "%VMOPTIONS_SOURCE%" does not exist
set ERROR_MESSAGE=Neither tws.vmoptions nor ibgateway.vmoptions could be found
set ERROR=%E_TWS_VMOPTIONS_NOT_FOUND%
goto :err
)
if defined JAVA_PATH (
if not exist "%JAVA_PATH%\java.exe" (
set ERROR_MESSAGE=%JAVA_PATH% does not contain the Java runtime executable
set ERROR=%E_NO_JAVA%
goto :err
)
)
echo =================================
echo.
::======================== Generate the classpath ===========================
echo Generating the classpath
set PHASE=Generating the classpath
set IBC_CLASSPATH=
for %%i in ("%JARS%\*.jar") do (
if not "!IBC_CLASSPATH!"=="" set IBC_CLASSPATH=!IBC_CLASSPATH!;
set IBC_CLASSPATH=!IBC_CLASSPATH!%%i
)
set IBC_CLASSPATH=%IBC_CLASSPATH%;%INSTALL4J%\i4jruntime.jar;%IBC_PATH%\IBC.jar
echo Classpath=%IBC_CLASSPATH%
echo.
::======================== Generate the JAVA VM options =====================
echo Generating the JAVA VM options
set PHASE=Generating the JAVA VM options
set JAVA_VM_OPTIONS=
for /f "usebackq tokens=1 delims= " %%i in ("%VMOPTIONS_SOURCE%") do (
set TOKEN=%%i
if not "!TOKEN!"=="" (
if not "!TOKEN:~0,1!"=="#" set JAVA_VM_OPTIONS=!JAVA_VM_OPTIONS! %%i
)
)
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -Dtwslaunch.autoupdate.serviceImpl=com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -Dchannel=latest
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -Dexe4j.isInstall4j=true
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -Dinstall4jType=standalone
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -DjtsConfigDir="%TWS_SETTINGS_PATH%"
set IBC_SESSION_ID="%RANDOM%%RANDOM%"
set JAVA_VM_OPTIONS=%JAVA_VM_OPTIONS% -Dibcsessionid=%IBC_SESSION_ID%
echo Java VM Options=%JAVA_VM_OPTIONS%
echo.
call :GetAutoRestartOption
echo.
::======================== Determine the location of java.exe ===============
echo Determining the location of java.exe
set PHASE=Determining the location of java.exe
if not defined JAVA_PATH (
if exist "%INSTALL4J%\pref_jre.cfg" (
for /f "usebackq tokens=1 delims=" %%i in ("%INSTALL4J%\pref_jre.cfg") do set JAVA_PATH=%%i\bin
if not exist "!JAVA_PATH!\java.exe" set JAVA_PATH=
)
)
if not defined JAVA_PATH (
if exist "%INSTALL4J%\inst_jre.cfg" (
for /f "usebackq tokens=1 delims=" %%i in ("%INSTALL4J%\inst_jre.cfg") do set JAVA_PATH=%%i\bin
if not exist "!JAVA_PATH!\java.exe" set JAVA_PATH=
)
)
if not defined JAVA_PATH (
if exist "%PROGRAMDATA%\Oracle\Java\javapath\java.exe" set JAVA_PATH="%PROGRAMDATA%\Oracle\Java\javapath"
)
if not defined JAVA_PATH (
set ERROR_MESSAGE=Can't find suitable Java installation
set ERROR=%E_NO_JAVA%
goto :err
)
echo Location of java.exe=%JAVA_PATH%
echo.
::======================== Start IBC ===============================
set PHASE=Starting IBC
if defined GOT_FIX_CREDENTIALS (
if defined GOT_API_CREDENTIALS (
set HIDDEN_CREDENTIALS="***" "***" "***" "***"
) else (
set HIDDEN_CREDENTIALS="***" "***"
)
) else if defined GOT_API_CREDENTIALS (
set HIDDEN_CREDENTIALS="***" "***"
)
:: prevent other Java tools interfering with IBC
set JAVA_TOOL_OPTIONS=
pushd %TWS_SETTINGS_PATH%
:startIBC
if exist "%PROGRAM_PATH%\tws.exe" (
echo Renaming tws.exe file to prevent restart without IBC
if exist "%PROGRAM_PATH%\tws1.exe" (
echo First delete existing tws1.exe file
del "%PROGRAM_PATH%\tws1.exe"
)
echo Rename tws.exe to tws1.exe
ren "%PROGRAM_PATH%\tws.exe" tws1.exe
)
if exist "%PROGRAM_PATH%\ibgateway.exe" (
echo Renaming ibgateway.exe file to prevent restart without IBC
if exist "%PROGRAM_PATH%\ibgateway1.exe" (
echo First delete existing ibgateway1.exe file
del "%PROGRAM_PATH%\ibgateway1.exe"
)
echo Rename ibgateway.exe to ibgateway1.exe
ren "%PROGRAM_PATH%\ibgateway.exe" ibgateway1.exe
)
echo.
echo.
echo Starting IBC with this command:
echo "%JAVA_PATH%\java.exe" -cp "%IBC_CLASSPATH%" %JAVA_VM_OPTIONS% %AUTORESTART_OPTION% %ENTRY_POINT% "%CONFIG%" %HIDDEN_CREDENTIALS% %MODE%
echo.
if defined GOT_FIX_CREDENTIALS (
if defined GOT_API_CREDENTIALS (
"%JAVA_PATH%\java.exe" -cp "%IBC_CLASSPATH%" %JAVA_VM_OPTIONS% %AUTORESTART_OPTION% %ENTRY_POINT% "%CONFIG%" "%FIX_USER_ID%" "%FIX_PASSWORD%" "%IB_USER_ID%" "%IB_PASSWORD%" %MODE%
) else (
"%JAVA_PATH%\java.exe" -cp "%IBC_CLASSPATH%" %JAVA_VM_OPTIONS% %AUTORESTART_OPTION% %ENTRY_POINT% "%CONFIG%" "%FIX_USER_ID%" "%FIX_PASSWORD%" %MODE%
)
) else if defined GOT_API_CREDENTIALS (
"%JAVA_PATH%\java.exe" -cp "%IBC_CLASSPATH%" %JAVA_VM_OPTIONS% %AUTORESTART_OPTION% %ENTRY_POINT% "%CONFIG%" "%IB_USER_ID%" "%IB_PASSWORD%" %MODE%
) else (
"%JAVA_PATH%\java.exe" -cp "%IBC_CLASSPATH%" %JAVA_VM_OPTIONS% %AUTORESTART_OPTION% %ENTRY_POINT% "%CONFIG%" %MODE%
)
::======================== Handle IBC exit conditions ==============
echo Program has exited
echo Error level is %ERRORLEVEL%
echo Check for 2FA dialog timed out
if %ERRORLEVEL% EQU %E_2FA_DIALOG_TIMED_OUT% (
if /I "%TWOFA_TO_ACTION%" == "RESTART" (
echo IBC will restart shortly due to 2FA completion timeout
ping localhost -n 2 >NUL
goto :startIBC
) else (
echo 2FA completion timed-out but TWOFA_TO_ACTION=EXIT so not restarting IBC
goto :NormalExit
)
)
echo Check for login dialog display timeout
if %ERRORLEVEL% EQU %E_LOGIN_DIALOG_DISPLAY_TIMEOUT% (
echo IBC will restart shortly due to login dialog display timeout
ping localhost -n 2 >NUL
goto :startIBC
)
echo Check for restart
echo call :GetAutoRestartOption
call :GetAutoRestartOption
if defined RESTART_NEEDED (
set RESTART_NEEDED=
echo IBC will autorestart shortly
ping localhost -n 2 >NUL
goto :startIBC
)
echo Check for cold restart
if exist "%TWS_SETTINGS_PATH%\COLDRESTART%IBC_SESSION_ID%" (
del "%TWS_SETTINGS_PATH%\COLDRESTART%IBC_SESSION_ID%"
set AUTORESTART_OPTION=
echo IBC will cold-restart shortly
goto :startIBC
)
:NormalExit
echo Normal exit
popd
echo.
echo %PROGRAM% finished at %DATE% %TIME%
echo.
exit /B %ERRORLEVEL%
::======================== Subroutines =============================
:GetAutoRestartOption
echo Finding autorestart file
set AUTORESTART_OPTION=
set F=
set RESTART_NEEDED=
for /f "usebackq delims=" %%I in (`where /R "%TWS_SETTINGS_PATH%" autorestart`) do (
set X=%%~dpI.
set Y=!X:%TWS_SETTINGS_PATH%=!
for /f "tokens=1,2 delims=\" %%B in ("!!Y!!") do (
if "%%C"=="." (
if not defined F (
set F=%%~fI
echo autorestart file found at !!F!!
set AUTORESTART_OPTION=-Drestart=%%B
) else (
set AUTORESTART_OPTION=
echo "WARNING: deleting extra autorestart file found at %%~fI"
del %%~fI
echo "WARNING: deleting first autorestart file found"
del !!F!!
)
)
)
)
if not defined AUTORESTART_OPTION (
if defined F (
echo *******************************************************************************
echo WARNING: More than one autorestart file was found. IBC can't determine which is
echo the right one, so they've all been deleted. Full authentication will
echo be required.
echo.
echo If you have two or more TWS/Gateway instances with the same setting
echo for TWS_SETTINGS_PATH, you should ensure that they are configured with
echo different autorestart times, to avoid creation of multiple autorestart
echo files.
echo *******************************************************************************
set RESTART_NEEDED=yes
) else (
echo autorestart file not found
set RESTART_NEEDED=
)
) else (
set RESTART_NEEDED=yes
)
goto :EOF
::======================== Error termination =======================
:err
echo.
echo =========================== An error has occurred =============================
echo.
echo.
echo.
echo Error: %ERROR_MESSAGE%
if not "%ERROR_MESSAGE1%"=="" (
echo %ERROR_MESSAGE1%
)
if not "%ERROR_MESSAGE2%"=="" (
echo %ERROR_MESSAGE2%
)
exit /B %ERROR%