Executing temporary bat files using TI

Ideas and tips for enhancing your TM1 application
Post Reply
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Executing temporary bat files using TI

Post by Wim Gielis »

Hello

I thought I would post up a simple example in a TI process to generate a batch file, execute it, and kill it.

The process creates the file usernames.bat in the folder C:\BV. After that, it executes the bat file and kills it again. As a result, the username in Windows is appended to the file C:\TM1\usernames.txt

Steps to reproduce:

Create a new process

In the Prolog tab:

Code: Select all

# 0. preliminary
vTempFileName='C:\BV\username.bat';
DatasourceASCIIQuoteCharacter='';

# 1. create the temporary bat file
ASCIIOUTPUT(vTempFileName,'cd "C:\TM1"');
ASCIIOUTPUT(vTempFileName,'echo %username% >> usernames.txt');
In the Epilog tab:

Code: Select all

# 2. execute the file
EXECUTECOMMAND(vTempFileName,1);

# 3. kill the temporary bat file again
ASCIIDELETE(vTempFileName);
Feel free to extend the approach taken, by making the bat file more "interesting". For instance, using the Metadata and Data tabs you could setup more difficult situations.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply