|
Answer» Can someone tell me how to use for in MS-DOS FOR LOOP I writed a BAT to copy other computers files to my computer But i don't konw how to use it ...
i used James2000's code to stoploop but it doesn't work.
i have forty-four computers.
Code: [Select]@echo off
set computer=s302-s0 set id=1
counting from net use \\%computer%%id% "password" /user:"%computer%%id%\admin" md z:\form1\%computer%%id% xcopy "\\%computer%%id%\d$\temp\*.*" "z:\form1\%computer%%id%\"
if %id%==9 goto stoploop set /A id=%id%+1 goto startloop
:stoploop echo Finished ! Does anyone know? The stoploop seems to be HANGING in OUTER space.
Code: [Select]@echo off
set computer=s302-s0
for /l %%x in (1,1,44) do ( net use \\%computer%%%x "password" /user:"%computer%%%x\admin" md z:\form1\%computer%%%x xcopy "\\%computer%%%x\d$\temp\*.*" "z:\form1\%computer%%%x\" ) echo Finished !
HAPPY coding.
PS. Is the password really password?
Thank you Sidewinder.
But i have another question, it is the the computer's netbios name.
Because computer 1 to 9 Netbios is s302-s01. When go to computer 10. Its name is s302-s10 .
So i want to use TWO for loop ^^"
Does it ok ?
Code: [Select]@echo off
set computer=s302-s
for /l %%x in (1,1,9) do ( net use \\%computer%0%%x "password" /user:"%computer%0%%x\admin" md z:\form1\%computer%0%%x xcopy "\\%computer%0%%x\d$\temp\*.*" "z:\form1\%computer%0%%x\" )
for /l %%x in (10,1,44) do ( net use \\%computer%%%x "password" /user:"%computer%%%x\admin" md z:\form1\%computer%%%x xcopy "\\%computer%%%x\d$\temp\*.*" "z:\form1\%computer%%%x\" )
echo Finished !
|