Variable and installation

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nerd
Posts: 7
Joined: 01 Jul 2010 03:39

Variable and installation

#1 Post by nerd » 01 Jul 2010 03:48

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.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Variable and installation

#2 Post by aGerman » 01 Jul 2010 06:04

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

nerd
Posts: 7
Joined: 01 Jul 2010 03:39

Re: Variable and installation

#3 Post by nerd » 01 Jul 2010 18:41

Thanks for your help :)

nerd
Posts: 7
Joined: 01 Jul 2010 03:39

Re: Variable and installation

#4 Post by nerd » 02 Jul 2010 03:14

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?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Variable and installation

#5 Post by aGerman » 02 Jul 2010 11:35

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

nerd
Posts: 7
Joined: 01 Jul 2010 03:39

Re: Variable and installation

#6 Post by nerd » 05 Jul 2010 18:33

Thanks aGerman, your a god send :)

Post Reply