executecommand() with batch files
-
- Community Contributor
- Posts: 103
- Joined: Mon Sep 05, 2011 11:04 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: executecommand() with batch files
See the attached screenshot. The column on the right shows the windows user which must have the correct permissions to run the bat file.
The TM1 user is irrelevant as all interaction between Windows and TM1 is done under the windows user set in the services console.
The TM1 user is irrelevant as all interaction between Windows and TM1 is done under the windows user set in the services console.
- Attachments
-
- services screenshot
- services.png (52.68 KiB) Viewed 8769 times
-
- Posts: 10
- Joined: Thu Oct 07, 2010 1:55 am
- OLAP Product: IBM Cognos TM1
- Version: 10.2.2 Fix pax 4
- Excel Version: 2013
Re: executecommand() with batch files
Hi Everybody,
Thanks to everyone.
The problem is solved, I tried with VB script and used executecommand () and it worked without any issues. I don’t why it didn’t work with .bat file, anyhow once again thanks to everyone.
Regards,
Thanks to everyone.
The problem is solved, I tried with VB script and used executecommand () and it worked without any issues. I don’t why it didn’t work with .bat file, anyhow once again thanks to everyone.
Regards,
-
- MVP
- Posts: 2836
- 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: executecommand() with batch files
Your batch file wouldn't run because, as yyi pointed out, you have to open a command window (with the cmd /c command) as part of the batch. Using VBScript you don't have to.l_kothamasu wrote:Hi Everybody,
Thanks to everyone.
The problem is solved, I tried with VB script and used executecommand () and it worked without any issues. I don’t why it didn’t work with .bat file, anyhow once again thanks to everyone.
Regards,
-
- Posts: 8
- Joined: Thu Apr 12, 2012 9:23 am
- OLAP Product: TM1, CX, MSAS, C8 BI
- Version: TM1 9.5.2 CX 9.5.0
- Excel Version: 2010
Re: executecommand() with batch files
Can you show how VB script launches via ExecuteCommand()?l_kothamasu wrote:...
The problem is solved, I tried with VB script and used executecommand () and it worked without any issues
...
As for me, it looks like VB script does nothing though I don't get any error messages.
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: executecommand() with batch files
CognosConnect wrote:Can you show how VB script launches via ExecuteCommand()?
Code: Select all
sCommand = 'cscript.exe YOUR_SCRIPT.vbs';
ExecuteCommand ( sCommand, 1 );
As the VBScript will run 'invisibly' then in order to debug the output you simply include text file output in your VB script e.g.:
Code: Select all
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="c:\test.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test string"
objFile.Close
Robin Mackenzie
-
- Posts: 8
- Joined: Thu Apr 12, 2012 9:23 am
- OLAP Product: TM1, CX, MSAS, C8 BI
- Version: TM1 9.5.2 CX 9.5.0
- Excel Version: 2010
Re: executecommand() with batch files
Thanks for your quick and such a detailed answer.
I call ExecuteCommand the same way.
I think that my problem lies on x86/x64 issues. So I tried to run script under 'C:\Windows\System32\cscript.exe' and under 'C:\Windows\SysWOW64\cscript.exe'. Both without result.
I was sure that my script does not run from TI Process at all because it work fine from within Windows Explorer or Command Prompt.
But your hint about some debug info led me to that the script crashes at:
Do You have any suggestion?
I call ExecuteCommand the same way.
I think that my problem lies on x86/x64 issues. So I tried to run script under 'C:\Windows\System32\cscript.exe' and under 'C:\Windows\SysWOW64\cscript.exe'. Both without result.
I was sure that my script does not run from TI Process at all because it work fine from within Windows Explorer or Command Prompt.
But your hint about some debug info led me to that the script crashes at:
Code: Select all
Set objExcel = CreateObject("Excel.Application")
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: executecommand() with batch files
On my system with 32-bit Excel 2010, a TI running under 64-bit TM1 will run 64-bit cscript which will automate 32-bit Excel with that CreateObject command. I'm not sure what version of Excel you are running?
Irrespective, it sounds like a permissions issue. The Excel automation will be attempted under the account that your TM1 service is running under. If this account isn't sufficiently privileged then you are going to have a hard time debugging the problem. Try running the TM1 service under a local admin account (with TM1 and Excel on the same box) and see what happens. If that's not possible then you may need to stuff around with dcomcnfg.exe or do some other sort of registry hacks. If you can't run TM1 as a local admin then trying these things is probably going to be difficult for you anyway and I'd suggest you are already in deep water and should look at some other method of automating your Excel processes.
Note that Microsoft do not recommend server-side automation of their Office products in the way you are trying to do:
Irrespective, it sounds like a permissions issue. The Excel automation will be attempted under the account that your TM1 service is running under. If this account isn't sufficiently privileged then you are going to have a hard time debugging the problem. Try running the TM1 service under a local admin account (with TM1 and Excel on the same box) and see what happens. If that's not possible then you may need to stuff around with dcomcnfg.exe or do some other sort of registry hacks. If you can't run TM1 as a local admin then trying these things is probably going to be difficult for you anyway and I'd suggest you are already in deep water and should look at some other method of automating your Excel processes.
Note that Microsoft do not recommend server-side automation of their Office products in the way you are trying to do:
Although it can be extremely useful and quick way of getting stuff done with TM1 and Excel, VBScript definitely falls under this bracket and therefore should be approached with much caution and robust error trapping.Microsoft wrote:Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
Robin Mackenzie
-
- Posts: 8
- Joined: Thu Apr 12, 2012 9:23 am
- OLAP Product: TM1, CX, MSAS, C8 BI
- Version: TM1 9.5.2 CX 9.5.0
- Excel Version: 2010
Re: executecommand() with batch files
TM1 service running under a local admin account
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: executecommand() with batch files
Best of luck then.... sounds like something funky is happening on your server, unfortunately.
Robin Mackenzie
-
- Posts: 8
- Joined: Thu Apr 12, 2012 9:23 am
- OLAP Product: TM1, CX, MSAS, C8 BI
- Version: TM1 9.5.2 CX 9.5.0
- Excel Version: 2010
Re: executecommand() with batch files
My problem was solved. It was not in the area of TM1.
Further localization of problem showed that error occurs exactly at method Workbooks.Open.
Thinking that there are some nuances exactly in TM1, I tried to run the script from SQL Server (using xp_cmdshell) and received the error message at the same point of script.
Further search led me to the answer:
http://blogs.msdn.com/b/sqlserverfaq/ar ... ected=true
Resolution
************
· A “Desktop” folder seems to be necessary in the “systemprofile” folder in the location C:\Windows\SysWOW64\config\ to open an Excel file
· Create the “Desktop” folder for Windows 2008 Server (x64) under the location C:\Windows\SysWOW64\config\systemprofile
· And for a 32 bit Windows 2008 Server create the “Desktop” folder under the location C:\Windows\System32\config\systemprofile
· After creating the folder the SQL Server jobs should execute successfully
In my case I create folder C:\Windows\SysWOW64\config\systemprofile\Desktop. And this fixes the problem.
----
Note again that there were no problems when executing a script in interactive mode (including when run it on behalf of the account under which the TM1 service starts).
This suggests that some in-depth interactions (such as COM/DCOM calls) nevertheless run under local system account (some "system profile"). And finally convinces in truth of rmackenzie's:
Further localization of problem showed that error occurs exactly at method Workbooks.Open.
Thinking that there are some nuances exactly in TM1, I tried to run the script from SQL Server (using xp_cmdshell) and received the error message at the same point of script.
Further search led me to the answer:
http://blogs.msdn.com/b/sqlserverfaq/ar ... ected=true
Resolution
************
· A “Desktop” folder seems to be necessary in the “systemprofile” folder in the location C:\Windows\SysWOW64\config\ to open an Excel file
· Create the “Desktop” folder for Windows 2008 Server (x64) under the location C:\Windows\SysWOW64\config\systemprofile
· And for a 32 bit Windows 2008 Server create the “Desktop” folder under the location C:\Windows\System32\config\systemprofile
· After creating the folder the SQL Server jobs should execute successfully
In my case I create folder C:\Windows\SysWOW64\config\systemprofile\Desktop. And this fixes the problem.
----
Note again that there were no problems when executing a script in interactive mode (including when run it on behalf of the account under which the TM1 service starts).
This suggests that some in-depth interactions (such as COM/DCOM calls) nevertheless run under local system account (some "system profile"). And finally convinces in truth of rmackenzie's:
Again, thanks a lot to Robin (rmackenzie)!rmackenzie wrote:Note that Microsoft do not recommend server-side automation of their Office products...