Unable to run ExecuteCommand() from TI

Post Reply
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Unable to run ExecuteCommand() from TI

Post by yingchai »

Dear members,

I am trying to call a simple batch file (located in C:\).

Below is my code.

Code: Select all


sBatchFile = 'C:\test.bat';
ExecuteCommand('cmd /c ' | sBatchFile, 0);

When I run this TI from my local, it is able to run perfectly. From my local the TM1 model service is started as Local System account.

If I run this TI from server, the batch file won't be triggered. I only received the message 'Process completed successfully'.
The difference between my local and server is...the TM1 model service is started via a domain user account in server. I had already assigned the domain user account to have full access to the batch file.

Please advise...
User avatar
gtonkin
MVP
Posts: 1202
Joined: Thu May 06, 2010 3:03 pm
OLAP Product: TM1
Version: Latest and greatest
Excel Version: Office 365 64-bit
Location: JHB, South Africa
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by gtonkin »

I would guess that the account on the server does not have access to execute files in the root of C: - try moving the batch file to where you know the server account has the correct permissions to read/execute.
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

I had done some further troubleshooting below:

1. Assign the domain user account (which runs the TM1 model service) to Administrator group in server.

2. Log in to server using the domain user account and able to execute the batch file.

3. Instead of running the batch file from C:\, I also try run the batch file from D:\ drive. It is able to run.

4. Assign 'Full Control' permission for the batch file to the domain user account.

But still, when I run the TI, the batch file is not triggered. PLS HELP!!!
User avatar
jim wood
Site Admin
Posts: 3952
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by jim wood »

Have you tried running with service with a local admin account instead? I don't know if this will solve the issue. I'm just trying to see if the service will be able to resolve a local account easier.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
tomok
MVP
Posts: 2832
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by tomok »

yingchai wrote:Instead of running the batch file from C:\, I also try run the batch file from D:\ drive. It is able to run.
Then why are you see adamant about running your batch file from the root of your C drive? As a general rule you should never do this to begin with. Just put it in the drive and folder you intend the final resting place to be and work from there.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

tomok wrote:
yingchai wrote:Instead of running the batch file from C:\, I also try run the batch file from D:\ drive. It is able to run.
Then why are you see adamant about running your batch file from the root of your C drive? As a general rule you should never do this to begin with. Just put it in the drive and folder you intend the final resting place to be and work from there.
Initially, I save the batch file in D:\ but got error when execute because it needs to run a winzip program. Saving in C:\ solved the batch file error.

Now, I created a simple batch file and save in a folder in D:\ drive.

I can't change the TM1 service to a local admin account as the Database server (contains the Data folder) is located in a separate server. Hence, the TM1 service needs to be started using a domain user account.

What other security issues that I need to attend to?
User avatar
qml
MVP
Posts: 1094
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Unable to run ExecuteCommand() from TI

Post by qml »

yingchai wrote:I can't change the TM1 service to a local admin account as the Database server (contains the Data folder) is located in a separate server. Hence, the TM1 service needs to be started using a domain user account.
The solution is staring you in the face. Make the domain account a local admin!
Kamil Arendt
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

qml wrote:
yingchai wrote:I can't change the TM1 service to a local admin account as the Database server (contains the Data folder) is located in a separate server. Hence, the TM1 service needs to be started using a domain user account.
The solution is staring you in the face. Make the domain account a local admin!
How to make domain account as local admin? I already assign the domain account into the server's Administrator user group.
User avatar
qml
MVP
Posts: 1094
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Unable to run ExecuteCommand() from TI

Post by qml »

yingchai wrote:How to make domain account as local admin? I already assign the domain account into the server's Administrator user group.
That's exactly the way to do it, add the account to the Administrators group. With that in place I don't think you should be having any more access-related problems. So are you having them?
Kamil Arendt
User avatar
jim wood
Site Admin
Posts: 3952
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by jim wood »

qml wrote:
yingchai wrote:How to make domain account as local admin? I already assign the domain account into the server's Administrator user group.
That's exactly the way to do it, add the account to the Administrators group. With that in place I don't think you should be having any more access-related problems. So are you having them?
QML, yingchai mentioned in an earlier post that this has been tried:
yingchai wrote:I had done some further troubleshooting below:

1. Assign the domain user account (which runs the TM1 model service) to Administrator group in server.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

I just did a further test on my local machine...

Previously, my model is started using the model shortcut. The TI was able to trigger the batch file.

Now, when I start my model from Services (created the TM1 Server from IBM Cognos Configuration), the TI was not able to trigger the batch file.

Please help...
lotsaram
MVP
Posts: 3660
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Unable to run ExecuteCommand() from TI

Post by lotsaram »

yingchai wrote:I just did a further test on my local machine...

Previously, my model is started using the model shortcut. The TI was able to trigger the batch file.

Now, when I start my model from Services (created the TM1 Server from IBM Cognos Configuration), the TI was not able to trigger the batch file.

Please help...
As has already been explained to you this is simply to do with permissions.

When you launch the model with a shortcut to tm1s.exe the model runs as an application with the credentials of the user running the application. When the model is running as a service then tm1sd.exe has the credentials of the user assigned in the properties of the service.

The solution is simple; just adjust the permissions of the service account user and make sure they are sufficient to run command line. If the user for the service is LOCAL SYSTEM and it doesn't work then you have a network policy which is throttling back the rights of the local system account. Unless you are a windows sys admin there is unlikely to be much you can do about this (if you were a windows sys admin I doubt you would have this question though). In which case you need to use another account to run the service, preferably one that has full local admin rights.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

Bottomline is, I already gave full Admin rights to the user's account which runs the model. This same user account is used to run the model using a shortcut or service.

Is it due to other settings rather than permissions?
User avatar
sachin
Posts: 92
Joined: Fri Jan 15, 2010 9:54 pm
OLAP Product: Transformer,SSAS, EP, TM1
Version: 7.3 2005 10.1 10.1.1
Excel Version: 2013
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by sachin »

yingchai wrote:Initially, I save the batch file in D:\ but got error when execute because it needs to run a winzip program. Saving in C:\ solved the batch file error.
yingchai wrote:I had done some further troubleshooting below:
1. Assign the domain user account (which runs the TM1 model service) to Administrator group in server.
2. Log in to server using the domain user account and able to execute the batch file.
3. Instead of running the batch file from C:\, I also try run the batch file from D:\ drive. It is able to run.
4. Assign 'Full Control' permission for the batch file to the domain user account.
But still, when I run the TI, the batch file is not triggered. PLS HELP!!!
So far my understanding is that:
  1. You are trying to run a batch file that calls winzip
  2. Which did not work when called from D drive, hence you moved it to C drive of your server
  3. When logged in through service account on the server, you are able to execute the batch file, present in C
  4. But this fails when called from TI using ExecuteCommand function
I could be wrong, however my suspicion is that UAC (User Account Control) in Windows server is prompting for a uid/pwd. Therefore, can you list the exact steps that you took, when trying to run the batch file from C drive, after you have logged on to the server with the service account?

I know you have been trying hard to find solution to make the batch file run from C drive. Perhaps it'd be easier, if you could fix the error that you were getting when you had it on D drive ... Just my thought.
Check out my blog for some good information on TM1, SPSS
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

sachin wrote:
yingchai wrote:Initially, I save the batch file in D:\ but got error when execute because it needs to run a winzip program. Saving in C:\ solved the batch file error.
yingchai wrote:I had done some further troubleshooting below:
1. Assign the domain user account (which runs the TM1 model service) to Administrator group in server.
2. Log in to server using the domain user account and able to execute the batch file.
3. Instead of running the batch file from C:\, I also try run the batch file from D:\ drive. It is able to run.
4. Assign 'Full Control' permission for the batch file to the domain user account.
But still, when I run the TI, the batch file is not triggered. PLS HELP!!!
So far my understanding is that:
  1. You are trying to run a batch file that calls winzip
  2. Which did not work when called from D drive, hence you moved it to C drive of your server
  3. When logged in through service account on the server, you are able to execute the batch file, present in C
  4. But this fails when called from TI using ExecuteCommand function
I could be wrong, however my suspicion is that UAC (User Account Control) in Windows server is prompting for a uid/pwd. Therefore, can you list the exact steps that you took, when trying to run the batch file from C drive, after you have logged on to the server with the service account?

I know you have been trying hard to find solution to make the batch file run from C drive. Perhaps it'd be easier, if you could fix the error that you were getting when you had it on D drive ... Just my thought.
I had turned off UAC before the test.

Ok. I'll list down my test below, using my local PC running on Windows 7. TM1 version is 10.2.2 FP4

Create a simple TI:

Code: Select all

sBatchFile = 'D:\Script\test.bat';
ExecuteCommand('cmd /c ' | sBatchFile, 0);
Here is the code for test.bat file:

Code: Select all

echo Starting file copy...
pause
Now, if you start the TM1 model using the application shortcut, the TI will probably able to trigger the .bat file.
Next, try to start the TM1 model as a service and see what you get.
User avatar
Alan Kirk
Site Admin
Posts: 6608
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Unable to run ExecuteCommand() from TI

Post by Alan Kirk »

yingchai wrote: Here is the code for test.bat file:

Code: Select all

echo Starting file copy...
pause
Now, if you start the TM1 model using the application shortcut, the TI will probably able to trigger the .bat file.
Next, try to start the TM1 model as a service and see what you get.
I've got a better idea.

How about instead of trying to echo to a screen from a service (which is not supposed to have a user interface) on a server (which will not normally have anyone logged on to see such an interface anyway)... you try redirecting that output to a file instead to determine whether the batch file is actually running?

Because my bet is that it IS actually running, and that if you consult the server's Task Manager and watch it reeeeal close... an extra cmd.exe session will pop up in the Details tab every time you run the process that calls the batch file, and it's just that the window, like the service itself, is not visible to you.

Except I wouldn't do that too often if I were you, because chances are you already have a raft of cmd.exe sessions running on the server, sessions which will not die until the server reboots because they're waiting in vain for a keystroke that will never come.

Needless to say, leave the "Pause" out of the batch file and go and take a look at the output file to confirm that it ran.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
yingchai
Posts: 43
Joined: Wed Nov 19, 2014 6:36 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Unable to run ExecuteCommand() from TI

Post by yingchai »

Alan Kirk wrote:
yingchai wrote: Here is the code for test.bat file:

Code: Select all

echo Starting file copy...
pause
Now, if you start the TM1 model using the application shortcut, the TI will probably able to trigger the .bat file.
Next, try to start the TM1 model as a service and see what you get.
I've got a better idea.

How about instead of trying to echo to a screen from a service (which is not supposed to have a user interface) on a server (which will not normally have anyone logged on to see such an interface anyway)... you try redirecting that output to a file instead to determine whether the batch file is actually running?

Because my bet is that it IS actually running, and that if you consult the server's Task Manager and watch it reeeeal close... an extra cmd.exe session will pop up in the Details tab every time you run the process that calls the batch file, and it's just that the window, like the service itself, is not visible to you.

Except I wouldn't do that too often if I were you, because chances are you already have a raft of cmd.exe sessions running on the server, sessions which will not die until the server reboots because they're waiting in vain for a keystroke that will never come.

Needless to say, leave the "Pause" out of the batch file and go and take a look at the output file to confirm that it ran.
GOOD SPOT Alan!

So, I had tested in both my local and server and concluded that:
- If TM1 server model started via application shortcut, the cmd window will appear in desktop.
- But if it is started via Services, cmd window will run on background.

I had myself to blame for not consulting Task Manager :(
Post Reply