1. Please help support our sponsors by considering their products and services.
    Our sponsors enable us to maintain high-speed Internet connection and fast webservers.
    They support this free information and knowledge exchange forum service at no cost to you.

    Please welcome our latest sponsor Tectrade . We can show our appreciation by learning more about Tectrade Solutions

Windows client script to update opt file

Discussion in 'TSM Client' started by Flounder, May 25, 2016.

  1. Flounder

    Flounder Newcomer

    Mar 4, 2015
    Likes Received:
    Does anyone have a script (bat, vbs, or powershell) that can modify the existing .opt file on a Windows Server Client?

    I need to update the backup server name, tcpport, and tcpserveraddress. I already have the tools to deploy the script, just need to modify the existing opt file.
  3. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Aug 24, 2005
    Likes Received:
    Electronics Engineer, Security Professional
    Somewhere in the US
    Here is something I wrote a while back and does exactly what you want. The DOS batch file is in two parts:

    Part 1 - replaces the parts like TCPSERVERADDRESS and TCPPort values:
    @echo off &setlocal
    set "search=%1"
    set "replace=%2"
    set "textfile=dsm.opt"
    set "orifile=dsm_ori.opt"
    set "newfile=dsm_mod.txt"
    copy %textfile% %orifile%
    (for /f "delims=" %%i in (%textfile%) do (
        set "line=%%i"
        setlocal enabledelayedexpansion
        set "line=!line:%search%=%replace%!"
    del %textfile%
    rename %newfile% %textfile%
    This script is saved as dsm_opt.cmd

    Part 2 - (1) implements the changes, (2) updates the password, and (3) restarts the TSM Service

    @echo off
    REM ****************************************
    REM sets the correct TSM Servername and Port
    REM ****************************************
    call dsm_opt.cmd <OLD_TSM_server_DNS_name> <NEW_TSM_server_DNS_name>
    call dsm_opt.cmd <OLD_TCPPort> <NEW_TCPPort>
    REM *****************************************************
    REM Updates the TSM userid and password on new TSM Server
    REM *****************************************************
    dsmcutil updatepw /node:%COMPUTERNAME% /password:%COMPUTERNAME%
    REM ******************************
    REM Restarts the right TSM Service
    REM ******************************
    sc query type= service state= all|find /i "TSM Client Acceptor" > tsm_srvc
    for %%a in (tsm_srvc) do set length=%%~za
    if %length% == 0 (
      net stop TSM Acceptor
      net start TSM Acceptor
    ) else (
      net stop TSM Client Acceptor
      net start TSM Client Acceptor
    del tsm_srvc
    You can save this to something like DSMOPT_Main.cmd

    As you can see, the TSM Server and TCPPort values are changed against TCPSERVERADDRESS and TCPPort options, respectively.

    The node name and password used here (in this case) is the Net BIOS server name.

    The last portion allocates for variances with the TSM Service naming. If you use a TSM CAD to initiate the TSM backup, all you need is to restart the TSM Client Acceptor service.


    The scripts MUST see the dsmcutil.exe path. Better yet, execute the scripts on where the dsmcutil.exe lives.

    All that is needed is to run DSMOPT_Main.cmd


    Added missed line: copy %textfile% %orifile%
    Last edited: May 25, 2016

Share This Page