Table of Contents

Starting TransSECS deployments automatically on Windows

A TransSECS deployment is the folder TransSECS builds for a project. It holds <ProjectName>Runtime.jar, ErgoTechConfiguration.properties, log4j2.xml and run.bat. Double-clicking run.bat starts the deployment in a console window. It stops when that window is closed, Ctrl+C is pressed in it, or the user logs off.

There are two ways to have a deployment start without anyone double-clicking run.bat:

Startup folder Windows service
Starts when the user logs in when Windows starts, before anyone logs in
Console window visible, like a hand-started deployment none; output goes to log files
If the deployment stops it stays stopped Windows can restart it
When the user logs off the deployment stops the deployment keeps running
Setting it up drag one shortcut, no extra software a Java copy, the WinSW wrapper and an .xml file; needs Administrator rights

Use the Startup folder on a machine where someone is always logged in and you want to see the console. Use a Windows service on an unattended machine, or where the deployment must keep running through log-offs and restart after a failure.

Before either: start the deployment once by hand with run.bat, on this machine, and check that it connects and that the log shows Valid IOT System Runtime License detected. See Running TransSECS deployments on the bottom half of this page. Licence and configuration problems are much easier to see in a console window.

1. Start the deployment when you log in (Startup folder)

  1. Press Windows key + R, type shell:startup and press Enter. This opens your own Startup folder. To start the deployment for every user who logs in, type shell:common startup instead. Adding to that folder needs Administrator rights.
  2. In File Explorer, open the deployment folder.
  3. Drag run.bat into the Startup folder with the right mouse button, and choose Create shortcuts here. Do not copy or move run.bat itself. It must run inside the deployment folder, because that is where it finds the runtime jar, the licence and the settings.
  4. Check the shortcut: right-click it, choose Properties, and make sure Start in is the deployment folder. Dragging fills this in for you.
  5. Optional: in the same Properties window, set Run to Minimized, so that the console window starts on the taskbar.
  6. Log off and log in again to check that the deployment starts.

Things to know:

2. Run the deployment as a Windows service

A Windows service starts with Windows, runs without a console window or a logged-in user, and can be restarted automatically if it stops. TransSECS uses WinSW 2.12.0, a small open-source program that runs a command as a Windows service.

In outline:

  1. Give the deployment its own Java. Copy the jre folder from <TransSECS installation>\MIStudioSuite\jre into the deployment folder, so that <deployment>\jre\bin\java.exe exists. A service does not use your PATH, and a copy keeps the service working when TransSECS is upgraded or removed.
  2. Add the wrapper. Copy WinSW-x64.exe into the deployment folder and rename it, for example to GEMHostService.exe.
  3. Configure it. Next to the .exe, create an .xml file with the same base name (GEMHostService.xml). It names the service, the Java command line taken from run.bat, the start mode, what to do on failure, and how the log files roll over.
  4. Install and start it. In a Command Prompt opened as Administrator in the deployment folder, run GEMHostService.exe install, then GEMHostService.exe start.
  5. Check it. GEMHostService.exe status should say Started. The console output is written to GEMHostService.out.log and GEMHostService.err.log in the deployment folder.

After that, the service can be started and stopped from the Services window (services.msc) like any other.

The full instructions, with an example .xml file to copy, what each setting does, how to change and remove the service, and what to check when it does not start, are on Running a TransSECS deployment as a Windows service.

3. Removing automatic start before you uninstall

Remove the Startup shortcut or the service before you delete a deployment folder or the TransSECS installation:

Otherwise Windows keeps trying to start a program that no longer exists. The uninstall-readme.txt file in the TransSECS installation folder (also opened by How to Uninstall in the ErgoTech Start menu folder) lists the other steps.