Batch File not kicking off another batch file - batch-file

I have created a batch(batA) file that kicks off another batch(marathon.bat) file. When I save batA onto my desktop and use
start /wait ..\marathon\marathon.bat -batch "C:\stuff"
it works just fine. However, when I save marathon.bat to my program files, which now has spaces in the name, and then use
start /wait c:\"Program Files (x86)\marathon\marathon.bat" -batch "c:\stuff"
I get the error:
'c:\Program' is not recognized as an internal or external command, operable program or batch file.
I know that you have to use double quotes so that it takes the spaces into consideration, but why is it stopping at c:\Program? I've tried moving the quotes around to different locations, but I can't seem to get it to recognize the second file.

Does this work for you?
start "" /wait %comspec% /c "c:\Program Files (x86)\marathon\marathon.bat" -batch "c:\stuff"

You have 2 problems with how you call your batch file.
First, you have placed your quotes at the wrong place. Instead of
start /wait c:\"Program Files (x86)\marathon\marathon.bat"
You should enclose your whole command with quotes, not only from the Program Files folder name:
start /wait "c:\Program Files (x86)\marathon\marathon.bat"
The second problem is that the first parameter with quotes specified to the START command is treated as the title of the new window. You should add an empty set of quotes before your command to circumvent this:
start "" /wait "c:\Program Files (x86)\marathon\marathon.bat"

Related

Create a batch file to run an .exe with one argument

I want to create a batch file that a user can run ... in the batch file I want to run an exe with one argument.
Here is what I have today:
#echo off
c:\
cd "C:\Program Files (x86)\App Location\App34\"
start HelperSetup.exe -arg
When I run that it opens up the cmd window and says the path cannot be found but i know for 100% it is the correct path.
I have tried to also pass in the string in a one line but no joy
"C:\Program Files(x86)\App Location\App34\HelperSetup.exe -arg"
I have tried to also pass in the string in a one line but no joy
When you want to also pass in the string in a one line you need to set the closing quote at the end of the path like this:
"C:\Program Files(x86)\App Location\App34\HelperSetup.exe" -arg
A much simpler approach for your batch script is to use the following command sequence
start /d "C:\Program Files (x86)\App Location\App34\" HelperSetup.exe -arg
This way, you don't need to change the drive and the cd command at all.

BATCH> run .exe files which paths are contained in a text file

I'm working on a start script, and I have a text file output.txt, containing paths to programs, like:
C:/program1.exe
C:/abab/program2.exe
How do I now run the programs contained in the text file via a batch script?
for /f "usebackq delims=" %A in ("C:\output.txt") Do Start "" "%A"
Start starts programs without waiting for them to exit (so new window) and first set of quotes is the window title. UseBackq is needed to use quotes around output.txt. See For /? and my answer here for how to start programs Trouble with renaming folders and sub folders using Batch. In a batch use %%A and %A when typing interactively (I don't use batch files, I keep stuff in one text file and paste parts into a command prompt window,which is interactive).
If they were to be run sequentially then
Rename the file to batch and run it. Open in notepad and search for / and replace with \ as that is the windows standard (although autocorrect will fix it without telling you but can sometimes cause problems).

Program will not run when called with start

I have the following code, but when I run it, nothing happens.
start /d "C:\Program Files\QLC\shared\jre1.6\bin" javaw.exe
exit
Start considers the first set of quotes it encounters to be the desired title of the window, regardless of where in the command those quotes are located.
To get around this, add a second set of quotes.
start "" /d "C:\Program Files\QLC\shared\jre1.6\bin" javaw.exe
exit
Also, javaw.exe by itself will not do anything. You must provide the program with a .class file or a .jar file to run.

How to change to a subdirectory and run an exe using a bat file in a Windows 7 system?

Using a bat file, I want to change to a sub directory of folder which bat file is in, and run my_application.exe in that directory,
I try:
cd /d %cd%\my subdirectory
START %~dp0my_application.exe
But it doesn't work, it says it can't find my_application.exe
Just indicate to start command what program to start and what should be the starting folder for it.
Without the cd command, it can be written as
start "" /d "%~dp0my_subdirectory" "my_application.exe"
if the my_application.exe is located in the subdirectory, or
start "" /d "%~dp0my_subdirectory" "%~dp0my_application.exe"
if the application is located in the same folder as the batch file.
start command take the first quoted parameter as the title for the new process. To avoid problems, a empty string ("") is included in command as the title.
Try:
cd /d "%~dp0my_subdirectory"
start "" my_application.exe
or just:
start "" "%~dp0my_subdirectory\my_application.exe"

what does start/wait means in batch file

In batch file, what does start/wait means
Example:
ECHO start/wait C:\\Example.exe
I am trying to run an exe, so what does start/wait indicates over here?
/wait forces the batch file to halt processing until the called program has finished executing.
(This can be useful, for example, if you are loading multiple items in your windows Startup folder, and the nature of the programs require that one be finished before the next starts loading. Put them all in a single batch file, using the /wait parameter, and only put a shortcut to the batch file in the Startup folder.) Command line parameters of the START command can be combined in a single line. Example:
START /max /wait NOTEPAD.EXE SOME.TXT
Source: http://aumha.org/a/batches.php

Resources