1. Community Tip: Please Give Thanks to Those Sharing Their Knowledge.
    If you receive helpful answer on this forum, please show thanks to the poster by clicking "LIKE" link for the answer that you found helpful.
  2. Community Tip: Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING)
    Click the link above to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This notice will disappear after you have made at least 3 posts.

Windows client script to update opt file

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

  1. Flounder

    Flounder Newcomer

    Joined:
    Mar 4, 2015
    Messages:
    4
    Likes Received:
    0
    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.
     
  2.  
  3. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,769
    Likes Received:
    352
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    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:
    Code:
    @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%!"
        echo(!line!
        endlocal
    ))>"%newfile%"
    
    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

    Code:
    @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.

    NOTE:

    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

    Edit:

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

Share This Page