Page 1 of 1

Variable and installation

Posted: 01 Jul 2010 03:48
by nerd
Hi, I am wanting to install a program into few hundreds computer.

My batch command at the moment includes copying the file from my local drive over the network computers and auto installation with psexec. Each installation takes around 2 minutes.

I am having an idea to just copy and paste all the IPs to a variable in a particular file, lets call it ABC. The batch file will call for the variable from ABC. Is there a way for me to just copy and paste all this IP under a variable without myself naming each variable? Thanks.

Re: Variable and installation

Posted: 01 Jul 2010 06:04
by aGerman
Think you could use a FOR loop to read the file. So you can use allways the same variable fo each iteration.
ABC.txt

Code: Select all

123.456.234.567
345.678.456.789




batch file

Code: Select all

@echo off &setlocal
for /f %%a in (ABC.txt) do (
  set "IPaddr=%%a"
  call :proc
)
pause
goto :eof

:: ~~~~~~~~
:proc
echo %IPaddr%
goto :eof



Place your stuff in subroutine :proc.

Regards
aGerman

Re: Variable and installation

Posted: 01 Jul 2010 18:41
by nerd
Thanks for your help :)

Re: Variable and installation

Posted: 02 Jul 2010 03:14
by nerd
I am trying to set different variables in a file (abc.txt)

set file1=c:\file2.exe
set file2=c:\file1.exe

How do I call for different variables (%file1%, %file2%) from abc.txt?

Re: Variable and installation

Posted: 02 Jul 2010 11:35
by aGerman
This way?

ABC.txt

Code: Select all

set file1=c:\file2.exe
set file2=c:\file1.exe




Batch file:

Code: Select all

@echo off &setlocal
for /f "delims=" %%a in (ABC.txt) do %%a

echo %file1%
echo %file2%
pause


[Edit: SET removed /]

Regards
aGerman

Re: Variable and installation

Posted: 05 Jul 2010 18:33
by nerd
Thanks aGerman, your a god send :)