Running TM1 as an application

Introduction

Any TM1 server can be run in one of 3 ways:

  1. TM1 runs as a service
  2. TM1 runs as an application
  3. TM1 runs as local server

Running a TM1 server as local server is not possible anymore since version TM1 10. Too bad. In this article, I give some guidelines on running TM1 as an application. Detailed information and custom code on running TM1 as a service, can be found here.

How to proceed?

Take the following steps to deploy TM1 as an application:

  1. create a shortcut to the file C:\Program Files\Cognos\TM1\bin\tm1s.exe (exact path may differ)
  2. right-click the shortcut and change the Target in the shortcut properties: add a space, then -z followed by the path of the TM1s.cfg file of the TM1 server to be loaded

An example of the shortcut location is: “C:\Program Files\Cognos\TM1\bin\tm1s.exe” -z“D:\TM1 models\Customer name” The latter folder contains the file tm1s.cfg, which in turn, will typically specify the TM1 server name, admin host, database directory, logging directory and MaxViewSize (a.o.).

No more manual steps

As a TM1 consultant, one uses applications for TM1 models very often, so we have many shortcuts and TM1s.cfg files as a result. As you know I am much into automating (relatively) tedious procedures, I wrote my own small vbs script to create the correct shortcut and start the TM1 server. Here is the script, the explanations follow after the code.

' Wim Gielis ' http://www.wimgielis.com
''''' ' Custom VBScript code to create a shortcut for running ' a TM1 server as an application, and loading the model ' 09/07/11 '''''
''''''''''''''''''''' '' '' user choices '' '''''''''''''''''''''
'file name of the shortcut Filename = "Customer name" 'path of the TM1s.cfg file PathCFG = "D:\TM1 models\Customer name" 'path where the shortcut should be created (leave empty so the desktop is chosen) PathShortcut = "" '"C:\" 'TM1s.exe location ServerEXE = "C:\Program Files\Cognos\TM1\bin\tm1s.exe"
''''''''''''''''''''' '' '' script '' ''''''''''''''''''''' 'Info: http://msdn.microsoft.com/en-us/library/yf7kaky2%28v=vs.85%29.aspx
On Error Resume Next Set fso = CreateObject("Scripting.FileSystemObject") With CreateObject("WScript.Shell") If Right(Trim(PathCFG), 1) <> "\" Then PathCFG = Trim(PathCFG) & "\" If Not fso.FileExists(PathCFG & "TM1s.cfg") Then _ MsgBox "Invalid choice of path of the TM1s.cfg file" : WScript.Quit (1) If Not fso.FolderExists(PathShortcut) Then PathShortcut = .SpecialFolders("Desktop") If Right(PathShortcut, 1) <> "\" Then PathShortcut = PathShortcut & "\" sFileName = PathShortcut & FileName & ".lnk" If fso.FileExists(sFilename) Then fso.DeleteFile sFileName With .CreateShortcut(sFileName) .TargetPath = ServerEXE .Arguments = "-z" & Chr(34) & PathCFG & Chr(34) .IconLocation = "tm1s.exe" .Description = "Load TM1 server: " & Trim(Replace(Replace(Filter(Split(fso.OpenTextFile(PathCFG & "tm1s.cfg").ReadAll, vbCrLf), "ServerName")(0), "ServerName", ""), "=", "", 1, 1)) .WindowStyle = 1 'or: 3 / 7 .Save End With .Run(sFilename) .Run("taskmgr") End With

Code logic

What the code above does (paste it into a .txt file and then change extension to .vbs):

  • The VBScript code creates a shortcut towards the folder containing the TM1s.cfg file. The user chooses this path.
  • You can decide where the shortcut should be located. If no entry or not a valid entry, the desktop is chosen automatically.
  • The shortcut has a description: it will contain the server name of the model to be loaded.
  • The model is loaded automatically, together with a Task Manager instance to know when you need to go back to work and stop surfing the world wide web.
  • In the line of code where the Arguments of the shortcut are set, you will notice the -z and the config path.
  • The Description shows some interesting twist: I will fetch the TM1 server name from the TM1s.cfg file directly.

I do hope you learnt something new today. I did!




Homepage

Section contents

About Wim

Wim Gielis is a Business Intelligence consultant and Excel expert

Other links