If you are unable to create a new account, please email support@bspsoftware.com

Author Topic: Calling cubeswap.bat in cognos script and passing cube name in a variable  (Read 16866 times)


  • Guest
Hi All,

I have a typical problem where my cubes have to be published on Cognos 8 portal. Each time the cube will be refreshed through a macro it will contain a new name in terms of a timestamp suffix. Through cubeswap.bat I want to point my portal data source connection to point to the refreshed cube.

It is kinda difficult to pass the new cube name in a variable in a bat file and use cubeswap. So i tried to call the cubeswap.bat with parameters within the macro through the shell function.

But, i am unable to do that .compliation errors are encountered at shell function. Can anyone suggest a way to remove the errors. Or any other way anyone has attempted the cube refresh in cognos 8.

My macro is as follows:

Code: [Select]
Sub Main

Dim objTransApp As Object
Dim objModel as Object
Dim objCube as Object
Dim strModelName as String
Dim strPath1 as String
Dim strPath2 as String
'Dim strModel as String
Dim strCube as String
Dim strCubeName as String
dim timestamp as String
Dim strModelPath As String
  Dim strLocation As String
  Dim strModelSource As String
  Dim newCubeName as String
  dim x
strLocation = "D:\Cognos\Model\Monthly_Sales\"
  strModelSource = "SalesModel.pyi"
  strModelPath = strLocation & strModelSource
timestamp = format(now,"ddmmyyyy_hhmmss_AM/PM")

'File names
strPath1 = "D:\Cognos\Cubes\"
strPath2 = "D:\Cognos\Cubes\Refresh_Cube\"
strModelName = "SalesModel.pyi"
strCube = "salescube.mdc"
newCubeName = "salescube"
'strModel = strPath1 & strModelName

'Creates new cube name

strCubeName = newCubeName & "_" & timestamp & ".mdc"

'Open model
Set objTransApp = CreateObject ("CognosTransformer.application.cer4")
Set objModel = objTransApp.OpenModel (strModelPath)
Set objCube = objModel.Cubes.Item(1)

'Build Cube

'Rename cube
FileCopy strPath1 & strCube, strPath2 & strCubeName

x = shell(D:\program files\cognos\c8\webapps\utilities\cubeswap

cubeswap.bat -dispatchername="http://micv92:9300" -datasource="test123"


-windowscube=strCubeName -username="c8administrator"

-password="cog01nos" -namespaceid="Default",1)


  Set objCube = Nothing
  Set objTransApp = Nothing
  Set objModel = Nothing

  MsgBox "Refreshed Sales Cube has been created"

End Sub

Please suggest a solution soon.

Thanks and Regards,

Aman Anand


  • Guest
Hello All,

I have been able to sort this issue out with help from Cognos Support.

Thanks and Regards,



  • Guest
What resolution did they provide?

Hello All,

I have been able to sort this issue out with help from Cognos Support.

Thanks and Regards,



  • Guest

They helped in sorting the problem with my macro.



Offline COGNOiSe administrator

  • Administrator
  • Statesman
  • ******
  • Posts: 675
  • Forum Citizenship: +32/-8
    • BrightStar Partners, Inc
Thanks for nothing, techieaman. We are here to help each other remember? You are not going to tell us what was the problem with your macro? If I had to guess I'd say the space between program and files was the issue, but I'm just speculating.


  • Guest

Apologies for my delayed response.  Problem was a bit weird as cubeswap was not working. Reason was the shell command unable to get into the d directory to pick the cubeswap utility.

So for this we added a line of code before getting to the cubeswap utility for changing the directory to D.

Which worked!

I hope this answers everyone's query.

If anybody needsthe macro just mail me on anandaman@gmail.com

Thanks again.