Announcement

Collapse
No announcement yet.

Help with a simple DOS batch script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with a simple DOS batch script?

    Hey guys, I'm trying to write a little batch script that passes its arguments to another program.

    I want the user to be able to type <I>foo.bat -x -y blah blah blah</I> and have it call <I>bar.exe -a -b -x -y blah blah blah</I>.

    I know about %1, %2, etc, but my problem is that I could have an arbitrary number of arguments. Does anybody know how I could work this?

    Thanks.
    Gigabyte P35-DS3L with a Q6600, 2GB Kingston HyperX (after *3* bad pairs of Crucial Ballistix 1066), Galaxy 8800GT 512MB, SB X-Fi, some drives, and a Dell 2005fpw. Running WinXP.

  • #2
    IIRC, you're stuck with %1 thru %9. Perhaps this has improved with Windows, but it doesn't seem like the sort of thing MS cares much about. Sorry
    Blah blah blah nick blah blah confusion, blah blah blah blah frog.

    Comment


    • #3
      This should work:
      Code:
      @echo off
      
      set foo_temp=
      
      :loop
      
      if "%1"=="" goto :exec
      
      set foo_temp=%foo_temp% %1
      
      shift
      
      goto :loop
      
      :exec
      
      bar.exe -a -b%foo_temp%
      
      set foo_temp=

      Comment


      • #4
        /me makes note of shift for future reference...
        Blah blah blah nick blah blah confusion, blah blah blah blah frog.

        Comment

        Working...
        X