Page 1 of 1

Executing temporary bat files using TI

Posted: Sat Oct 03, 2009 1:20 pm
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.