Windows client script to update opt file

Flounder

Newcomer
Joined
Mar 4, 2015
Messages
4
Reaction score
0
Points
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.
 
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:
Back
Top