Batch Files

By paulhenrydanna
Feb 26, 2008
  1. Posting new Threads / Batch Files

    It has been a long time since I used this site. I had a hard time finding where to make a new post, even though I had done it previously.

    My situation is that I want to pass a paremeter in my batch file. The file is rather simple.

    IF %1 = "3" XCOPY w:/*.* C:\OLDDOCS\ /S/V/Y/D
    cd c:\Billing\Progs
    vfp9.exe Main.Prg

    I only want to execute the "XCOPY" command when the parameter is "3".

    What happens is that when the parameter is "3", the "XCOPY" command will execute, but none of the commands that follow it.

    If the parameter is not "3", then nothing executes.

    If I remove "IF %1 = "3" ", then every thing executes.

  2. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    You managed to post in the wrong forum. I don't see why you wouldn't be able to post in the correct forum..

    Anyway, use a goto statement and reverse logic instead. Something like
    IF NOT %1 = "3" GOTO :end
  3. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    Sorry.. I misunderstood your problem. Anyway, you are supposed to use == in if statements, not =.
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...