1

Is it possible to start another batch file and pass along multiple parameters with spaces, using the start command?

Here is how my program currently works:

main program starts > sees its outdated > calls updater (data1.exe) > updater copies new version over > It tries to delete the old version, but it can't. The old version is still marked as being used, from when it called the updater.

That's why the call command won't work. Do I need to use start then? How would that work?

This was the original line of code... the one that calls the updater and passes the variables along:

call "%dirofbatch%data1.exe" "%downloc%" "%dirofbatch%" "%lver%" "%lget%"

I'm stumped.

EDIT: I should mention that "data1.exe" is just an exe'd batch file.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
magicbennie
  • 423
  • 3
  • 8
  • 20
  • Do you want to delete a running program ('main program')? You should show more code from your batch. what is `%dirofbatch%` exactly? – Endoro Aug 11 '13 at 06:58
  • 1. Yes, I want to use the updated version of the main program and delete the old version, which is apparently still running. 2. The %dirofbatch% is essentially, "%~dp0". – magicbennie Aug 11 '13 at 07:09
  • Windows doesn't allow to delete running apps. – Endoro Aug 11 '13 at 07:17
  • That's why i'm asking if the 'start' command would work instead. The start command starts the specified program in a separate window. So how would I pass those 4 variables to the updater? – magicbennie Aug 11 '13 at 07:29

1 Answers1

4

How to read parameters in a batch file:

  1. caller batch

    start "" "%dirofbatch%data1.exe" "%downloc%" "%dirofbatch%" "%lver%" "%lget%"
    
  2. called batch

    set "parm1=%~1"
    set "parm2=%~2"
    set "parm3=%~3"
    set "parm4=%~4"
    echo %parm1% %parm2% %parm3% %parm4%
    
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • I think you may be a bit confused :P – magicbennie Aug 11 '13 at 08:10
  • I can't use the call command because it keeps the caller program alive... and because the caller program is still alive, i can't delete it. I need to know how to pass variables to the 2nd batch file (data1.exe) with the START command, NOT the CALL command, so that the updater runs in a separate window. – magicbennie Aug 11 '13 at 08:16