How script install Controller Client for more environments?

Product:
Cognos Controller 10.4
Microsoft Windows 2016

Problem:
How create one silent install package, that can install to different environments. If the install script run in DEV it should point to the DEV controllerserver (e.g. by updating the ccr.exe.config file), same script should work for PROD.

Suggested Solution:
In case your terminal servers host name point out if it is DEV or PROD, like this;
DEV servers have TT in there servername like TT2345.
PROD servers have SRV in there servername like SRV2345, and PPE have PP in the servername.
Then you can create 3 uniq ccr.exe.config files, with a predefined line for each environment;
<add key=”WSSUrl” value=”http://DEVSERVER.COMPANY.COM/ibmcognos/controllerserver”/>


Place all files in the same folder on the server. 3 files of ccr.exe.config, with the middle part replaced with the environment tag. The client ccrlocalclient64.msi file and a BAT file with below code;
REM=================replace italic with your values=========
cd /D %~dp0
msiexec /qb /i CCRLocalClient64.Msi IBM_COGNOS_CONTROLLER=”C:\Program Files\IBM\IBM Cognos Controller Local Client” WSSURL=http://controllerserver.company.com/ibmcognos/controllerserver HELPURL=http://webserver.company.com/ibmcognos/documentation/en/welcome.html

@setlocal enableextensions enabledelayedexpansion
@echo off
set COGNOSVAL=NULL
call :CheckEnv %COMPUTERNAME%
call :CopyFile

Goto ScriptEND

:CheckEnv
echo %1
set str1=%1
if not x%str1:tt=%==x%str1% set COGNOSVAL=DEV
if not x%str1:pp=%==x%str1% set COGNOSVAL=PPE
if not x%str1:srv=%==x%str1% set COGNOSVAL=PROD
Goto END

:CopyFile
copy /Y ccr.%COGNOSVAL%.config “C:\Program Files\IBM\IBM Cognos Controller Local Client\CCR.exe.config”
copy /Y CognosController.ps1 “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\CognosController.ps1”
Goto END

:ScriptEND
endlocal
:END
REM=====================end of code==============

We also copy a ps1 file to the startup folder of Windows 2016.
The powershell cognoscontroller.ps1 file is run when a user logon to the terminal server, in that ps1 script you can have code to set that excel can open XLT files, and other things.

Update the BAT file with the your prod servers WSSURL and HELPURL, if the servername does not match Controller client is installed with this values.

Above show the line to update in the ccr.exe.config file.
The content of this file is copied to the users windows profile C:\Users\username\AppData\Roaming\Cognos\ccr\ccr.config, when they start Cognos Controller Client for the first time.
To make above work, the Terminal Servers should not use a roaming profile.
Run the BAT file to install Cognos Controller, and it will copy the correct ccr.exe.config file to your program files folder.

More Information:
https://docs.microsoft.com/en-us/windows-server/storage/folder-redirection/deploy-roaming-user-profiles
https://ss64.com/ps/push-location.html
https://www.tachytelic.net/2017/10/find-startup-folder-windows-server-2012-windows-server-2016/

https://www-01.ibm.com/support/docview.wss?uid=swg21640592

https://www-01.ibm.com/support/docview.wss?uid=swg21967963

https://allthingscognos.wordpress.com/category/cognos-controller/