Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Having trouble with multiple steps within a FOR loop  (Read 2490 times)

0 Members and 1 Guest are viewing this topic.

Tommy Lightfingers

  • Guest
Having trouble with multiple steps within a FOR loop
« on: May 12, 2009, 10:34:54 AM »
Here's the sit:
I've tried two different tactics on this problem.  They are:

REM FOR %%F IN (*.) DO (NET USE Z: \\%%F\C$\WINDOWS\TASKS
REM         DEL Z:\AT*.JOB
REM         NET USE Z: /DELETE)

and

REM FOR %%F IN (*.) DO (NET USE Z: \\%%F\C$\WINDOWS\TASKS
REM         DEL Z:\AT*.JOB
REM         NET USE Z: /DELETE)

The batch file will be run from C:\BATCH\JOBCLEAN\JOBCLEAN.BAT with C:\BATCH\JOBCLEAN\ containing one file for each computer name on the LAN.  I've got a simpler batch file that runs well using the same setup.  It is:

for %%f in (*.) do delprof /c:\\%%f /d:30 /q /i (where delprof is an external executable stored in the directory with the batch file.)

Here's the question.  How can I get a for loop to run multiple commands for the same %%F variable before going on to the next one?  I really don't want to learn VB Script right now as I'm learning SQL and I don't want to get confused.  My computer is running MS Win XP SP3, 2Gb RAM on an TCP/IP network.  This will be running against roughly 400 machines which I have administrator access on.

macdad-



    Expert

    Thanked: 40
    Re: Having trouble with multiple steps within a FOR loop
    « Reply #1 on: May 12, 2009, 11:19:05 AM »
    If you want it to wait until the command is finished then you can put each command into a seperate batch file and use this command:

    Code: [Select]
    Start "batch.bat" /WAIT %%F
    This would pause the calling batch file until Batch.bat is completed.

    Batch1:
    Code: [Select]
    @echo off
    NET USE Z: \\%1\C$\WINDOWS\TASKS

    Hope this helps
    ,Nick(macdad-)

    If you dont know DOS, you dont know Windows...

    Thats why Bill Gates created the Windows NT Family.