Note the line where the path is. Please adjust to your NTFS location

@echo off

set filenm="C:\Program Files (x86)\Citrix\Independent Management Architecture\MF21.dsn"

set sqlserver=sqlcluster

set sqlDB=CrouseCTXFarm

set citrixdesc=CrouseCTXFarm

set citrixuser=CrouseCTXFarm

set /p citrixpass=Set the Data Store Password for user (%citrixuser%) +ENTER:

set citrixServiceIMA="Citrix Independent Management Architecture"

set citrixServiceSMA="Citrix SMA Service"

set citrixServiceWMI="Citrix WMI Service"

echo Starting...

echo Using: %filenm%

if NOT EXIST %filenm% goto SkipDel

echo Removing current file to replace with new one

del %filenm%


echo Creating DSN File

echo [ODBC] >> %filenm%

echo DRIVER=SQL Server >> %filenm%

echo UID=%citrixuser% >> %filenm%

echo DATABASE=%sqlDB% >> %filenm%

echo WSID=%computername% >> %filenm%

echo APP=Citrix IMA >> %filenm%

echo SERVER=%sqlserver% >> %filenm%

echo Description=%citrixdesc% >> %filenm%


echo Reconfigure the pointers to the Datastore:

rem echo /user:%citrixuser% /pwd:%citrixpass% /dsn:%filenm%


DSMAINT CONFIG /user:%citrixuser% /pwd:%citrixpass% /dsn:%filenm%


echo Stopping and restarting the IMA, SMA, and WMI Services.

net stop %citrixServiceWMI%

net stop %citrixServiceSMA%

net stop %citrixServiceIMA%

dsmaint recreatelhc

net start %citrixServiceSMA%

net start %citrixServiceWMI%

net start %citrixServiceIMA%

echo Finished.