Page 1 of 1
TI firing program not working
Posted: Thu Jun 11, 2015 10:37 am
by TrevorGoss
Hello all,
I have a simple TI which calls a batch via the executeCommand function. The syntax is simple:
Code: Select all
ExecuteCommand('z:\path\Folder\batch.bat',0)
The batch then fires a C# program which will shut down a TM1 windows service.
But the TM1 windows service never shuts down.
My C# program creates files, which get created upon the TI call to the batch to the program, but the windows service its self does not shut down....but..it does when I fire the batch manually.
My batch is also simple:
Code: Select all
z:
dir > beforecall.txt
REM -- arg1,2 are the arguments for the program
start z:\folder\CloseService.exe arg1 arg2
dir > afterCall.txt
the dir calls are creating text files to make sure the batch works.
When I fire the TI which fires the batch it creates these two files and the file from the program but it does not shutdown the windows service, even though it does so when run manually.
I know the documentation for the ExecuteCommand says this:
You can use ExecuteCommand to run a desktop application, but not a service.
But I am not using the ExecuteCommand function to work with a service...the function is calling a batch that calls a C# program which shuts off the server.
To re cap - Firing a TI which fires a batch which fires a C# program, creates files from the C# program and from the batch but does not shut down a windows service from the C# program.
It will however work if I fire the batch manually.
Any ideas? Any help would be great.
Thank you.
Re: TI firing program not working
Posted: Thu Jun 11, 2015 2:55 pm
by BrianL
I'd assume that anything called by ExecuteCommand runs as the same user that TM1 is running under and therefore has the same security permissions. Does this user account have permissions to stop the service? Have you run the command manually as that user?
Re: TI firing program not working
Posted: Thu Jun 11, 2015 3:36 pm
by TrevorGoss
Hello, thanks for the response
I'd assume that anything called by ExecuteCommand runs as the same user that TM1 is running under and therefore has the same security permissions. Does this user account have permissions to stop the service?
The account does have the correct permissions, I am admin for the relevant server.
Have you run the command manually as that user?
I have, it works fine when I skip the TI running the ExecuteCommand part, I run the batch that is called from the TI and it prints out text files and shuts down a TM1 windows service.
When I run it from the TI it provides me with the files, but leaves the windows service alone.
Re: TI firing program not working
Posted: Thu Jun 11, 2015 4:09 pm
by qml
Trevor, from your reply I am not sure you understood what Brian is asking about, so just to make sure:
- The TM1 service (and therefore any commands executed by it) is running under one account (account A).
- You are logged on as you (account B).
Account A and B can be the same account, but are probably not. Have you tried running your script as account A to see if it's a permissions issue? I agree that it does look like one.
Re: TI firing program not working
Posted: Thu Jun 11, 2015 11:56 pm
by failurehappening
Not an answer to why it's not working, but the way I shut down services from TM1 is with the following:
Code: Select all
sQuote = CHAR(34);
sCmd = 'cmd /c sc \\' | pAdminHost | ' STOP ' | sQuote | pService | sQuote ;
ExecuteCommand ( sCmd,0 );
Copy your code across or whatever you're doing and then use the same command with the flag ' START ' to bring it up again:
Code: Select all
sCmd = 'cmd /c sc \\' | pAdminHost | ' START ' | sQuote | pService | sQuote ;
ExecuteCommand ( sCmd,0 );
This assumes that whatever account the TM1 instance you run it from has administrator privileges on the pAdminHost .
Re: TI firing program not working
Posted: Fri Jun 12, 2015 8:13 am
by TrevorGoss
Thanks for all of your replies,
Not an answer to why it's not working, but the way I shut down services from TM1 is with the following:
Code: Select all
sQuote = CHAR(34);
sCmd = 'cmd /c sc \\' | pAdminHost | ' STOP ' | sQuote | pService | sQuote ;
ExecuteCommand ( sCmd,0 );
I ran this TI and it worked for the same host that the TI ran on, it stopped a TM1 windows service, demonstrating that it is possible.
I tried to aim it at a different server and it did not work. however, it does work if I run it on a different TM1 service aiming the command at a TM1 windows service on a different server.
So it works for one TM1 model but not another, telling us that it is an access issue.
Kamil, unless I have missed somthing, it is always me, an admin running the TI. The TI transcends servers when possible so it must be somthing to do with the rights contained inside a model, as I am admin on both.
Thanks.
Re: TI firing program not working
Posted: Fri Jun 12, 2015 8:28 am
by TrevorGoss
Hello again,
I have solved the issue.
It was indeed security rights, it all depends on what account the TM1 windows service is running with, with a "Local System" logon it will not transcend servers, but with the right logon it does.
Brian/Kamil, is this what you meant?
Thanks guys.
Trevor.
Re: TI firing program not working
Posted: Fri Jun 12, 2015 2:24 pm
by qml
Trevor, I don't know where you got 'TI transcends servers when possible' from, but it's simply not true. Any interaction with the world outside the TM1 service is done using the service account TM1 is running under ('Local System' or another account). As such, it only matters what rights that very service account has to manipulate objects outside of the TM1 service.
Re: TI firing program not working
Posted: Fri Jun 12, 2015 3:03 pm
by tomok
Just because you personally can run a batch file, meaning the syntax is correct, does not mean that a TI process will be able to. When you test your process that way you are only proving out a part of it. You still have to consider Windows access security rights. As long as you are working inside the confines of TM1, like browsing a cube, updating a dimension, running a report, etc., then all that matters is your security privileges in TM1. Once you leave the confines of TM1 (and that includes tasks done inside a TI process), such as accessing an ODBC data source, writing to a flat file, running a program under the ExecuteCommand function then what really matters is the security privileges of the TM1 service. If you are running that under "Local System" then you are only going to be able to do stuff that the account "Local System" can do. You're TI process won't be able to write to or access a flat file on any other machine, you won't be able to run a batch file that accesses another machine, etc. However, if you switch the TM1 service to run under a Windows account you can give that account rights to all kinds of stuff and then your TI will be able to do those things you want.
Re: TI firing program not working
Posted: Mon Jun 15, 2015 8:18 am
by TrevorGoss
Kamil,
Trevor, I don't know where you got 'TI transcends servers when possible' from, but it's simply not true.
Fair enough, I should of said the consequences of the TI transcend servers, maybe that would of been more sympathetic to the situation.
Tom,
You're TI process won't be able to write to or access a flat file on any other machine, you won't be able to run a batch file that accesses another machine, etc. However, if you switch the TM1 service to run under a Windows account you can give that account rights to all kinds of stuff and then your TI will be able to do those things you want.
Agreed.
Thanks for your help guys, the problem has been resolved.
Trevor.