Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi.
I hve written a batch file which connects to a series of computers, checks for the existence of a file then published the result, however I have a different section in the batch file for for each PC. What I want to do is to have a serperate list of ip addresses which I can include as variables.Here is an example of the batch file I am using. This is for 1 PC so for 20 you can imagine how unweilding it is becoming.
REM *****Room number B002*****
time /t > timeb002.txt
net use j: \\xx.xx.xx.xx\c$ password /user:administrator /y
copy smile.gif j:\temp
if not exist j:\temp\smile.gif goto badcopy1
copy timeb002.txt h:\tmp\ltcheckgoto goodcopy1
:badcopy1
copy bad.tnt h:\tmp\ltcheck\timeb002.txtgoto end
:goodcopy1
del j:\temp\*.gif
:end
net use j: /delete /y
Thanks in advancePete

Hi
Will something along these lines help.
Create a file with your data similar to the data below
showing room + IP address
and have the first batch file call the second batch file
with Room and IP address from each line in the IP data file.
Hope this may be of some help. I'm no expert.
Harry.Rem IP.dat File
001 123-456-789
002 223-456-789
003 323-456-789
004 423-456-789
005 523-456-789
006 623-456-789
007 723-456-789
008 823-456-789
009 923-456-789
010 123-456-789
Rem Batch File1
echo off
for /f "tokens=1,2 delims= " %%a in (ip.dat) do call Test2.bat %%a %%bRem Batch File2
@echo off
REM *****Room number B002*****
time /t > timeb%1.txt
echo net use j: \\%2\c$ password /user:administrator /y
copy smile.gif j:\temp
if not exist j:\temp\smile.gif goto badcopy1
copy timeb%1.txt h:\tmp\ltcheck
goto goodcopy1
:badcopy1
copy bad.tnt h:\tmp\ltcheck\timeb%1.txt
goto end
:goodcopy1
j:\temp\*.gif
:end
net use j: /delete /y

Thanks very much that felt expert to me!!!!
Thanks again that really has made my life easier, I'd looked at the 'for in do' command but couldn't get my head round the tokens...
Most grateful!!
Pete

Hi Pete
Glad it made your life easier.The Tokens are just like line parameters and the delims are just what seperates them, in this case a space.
the tokens passed to the second batch file are the two tokens from the data file ie Room No & IP Address these are
taken as data to the second batch file as %1=Room No and %2=IP Address for every line in the data file.
Hope this Helps.
Harry

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |