I am installing multiple services (using dsmcutil) from CMD batch file in windows 2012 however while dsmcutil command lien is correct variables created in for /f do not work properly. I guess it is a similar behavior known as globing
I tried syntax as follow (dsmcutil command is tested and correct, )
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
set cpath=C:\Program Files\tivoli\TSM\baclient\cifs
set dpath=C:\Program Files\tivoli\TSM\baclient
set dsmcutil=%dpath%\dsmcutil
set User=service_user
set UserPa=sjkdfIHO127346JHG
set pass=xxxkkk123
set ntdo=polka.net
for /F "usebackq tokens=*" {%A} IN "%cpath%\nodes.lst" do (
set mopt=%cpath%\%A\%A-dsm.opt
%dsmcutil% install sched /name:"TSM Client Scheduler %A" /node:%A-m /password:%pass% /eventlogging:no /optfile:"%mopt%" /schedlog:"%cpath%\%A\DSMSched_%A.log" /errorlog:"%cpath%\%A\DSMError_%A.log" /startnow:yes /autostart:yes /ntdomain:%ntdo% /ntaccount:%User% /ntpassword:%UserPa%
)
the error I get is "cpath\nodes.lst" do ( was unexpected at this time."
The question is what is proper syntax working on windows 2012 r2? ..... if You call the variable from "for" in the syntax normally it was %A% which gives the same error as %A only. Moreover (for /F "usebackq tokens=*" %A ) has to be used and not %%A as in previous w2k versions.
syntax normally should endup getting : 1. path/node_name (from for loop and txt file = nodes.lst) 2. pointing to right path\dsm.opt file 3. executing dsmutil installing service with the right name.
as it is it never gets over point 1.