I am executing a batch script to perform operations on services in a server. so i am giving a ui to user to select a list of services from a server. i cab perform this operation if user selects only one service. I want to know how to perform if users selects multiple services as this services will be passed as a parameter to the batch file. I tried this for a single service.
set /a ArgCount = 0
for %%a in (%*) do (
set /a ArgCount += 1
set "argVec[!ArgCount!]=%%~a"
)
if !ArgCount! LSS 2 (
echo Arguments missing
goto :eof
)
set server=%1
set serviceName=%2`
SC \\%server% query "%serviceName%" | find "STATE" | find "RUNNING"
If ERRORLEVEL 1 goto :start
:start
cmdkey /add:%server% /user:%username% /pass:%password%
sc \\%server% start "%ServiceName%"
I want to know how to modify this script when user selects more than one or multiple services on remote desktop.