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.
Related
To recreate my problem you need to understand that I have next files in 2 folders.
K:\Script.bat
K:\Project\PortChanger.exe
K:\Project\settings.xml
I want to launch PortChanger.exe using Script.bat that contains next line:
start "K:\Project\PortChanger.exe"
This script is actually executing Program.exe, but my program throws me exception since PortChanger.exe can't find Settings.xml.
How can I launch PortChanger.exe from "K:\Project\", not from "K:\"? Now it seems like .BAT taking .EXE code and just running it where .BAT is locating.
To make it even more clear:
You could use Start with its /D option:
Start "" /D "K:\Project" "K:\Project\PortChanger.exe"
Open a Command Prompt window and enter start /? to read its usage information.
I would suggest you rather use pushd and popd
#echo off
pushd "K:\Project"
start "" PortChanger.exe
popd
pushd will change to the directory, launch the executable from it, then popd will return to the previous directory stored.
I want to make a batch file that runs a particular program and then the command window exits itself, I tried this cause i will make a shortcut of that batch file so the batch file is in root directory
#echo off
"program.exe" "mainframe.pkg"
exit
it works but the black windows doesn't disappear and causes a fuss in the program cause it has perimeters. Any way to remove the black ugly CMD window.
Use the start command.
#echo off
start "" "program.exe" "mainframe.pkg"
The first quoted string after the start command is a console window title (if you are starting a console program); it can be an empty string as in my example. After that, specify the program name and its parameters.
You do not need the exit command at the end of the script. (In fact, I recommend against it without the /b parameter, because if you run the script from a cmd.exe prompt, your cmd.exe window will close without warning.)
You need to add exit 0 to the end of your program like so:
#echo off
start "program.exe" "mainframe.pkg"
exit /B 0
This should work, but let me know!
#echo off
start /B "" "program.exe" "mainframe.pkg"
exit /B 0
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"
So, I'm trying to setup a basic script to install WinRAR (as my test, others later on) and I' can't seem to get it to work. Here's what I have:
#ECHO OFF
IF EXIST "C:\Program Files (x86)\WinRAR" GOTO End
IF EXIST "C:\Program Files\WinRAR" GOTO End
IF DEFINED ProgramFiles(x86) (
START C:\WinRAR_4.20_(x64).exe
) ELSE (
START C:\WinRAR_4.20_(x86).exe
)
:End
PAUSE
The first two EXIST checks work fine, but I can't get the START command to work. If I just type it out in the CMD window it starts up the installer, but it just wont do it from the batch file.
Can someone point me to where I'm screwing up?
The problem is with the FileName. Get rid of parenthesis in the file name and it should work fine. WinRAR_4.20_x64.exe and WinRAR_4.20_x86.exe
the start command requires a string for the title of the window, for instance,
start "" apples.exe
will start apples.exe with the title of the console window as
currently you are telling the start script that the title of the console window should be:
C:\WinRAR_4.20_(x64).exe
You should type in the following:
start "" "C:\WinRAR_4.20_(x64).exe"
It worked on first time only.Non of this options.
start "" C:\Program Files (x86)\MSI\Command Center\CommandCenter.exe
2)START /d start "C:\Program Files (x86)\MSI\Command Center" CommandCenter.exe
I have a batch script that eventually starts another batch file and waits for it to complete. Here is the syntax I originally had:
for %%i in ("*.xml") do start /separate /wait "%PROGRAM_PATH%" "%LOCAL_OUTGOING_PATH%\%%i"
What happened is that instead of opening the program that %PROGRAM_PATH% points to, it ended up launching Internet Explorer and showing the XML file specified by %%i. It was like as though it ignored the %PROGRAM_PATH% portion of the start command. I tried using %PROGRAM_NAME% without quotes that didn't work either. %PROGRAM_PATH%, by the way, points to "
"C:\DOS\copy.bat". So I ended up having to hard code the path in there like this:
for %%i in ("*.xml") do start /separate /wait C:\DOS\copy.bat "%LOCAL_OUTGOING_PATH%\%%i"
This made it finally work the way I wanted it to. But I want to be able to use a variable. Why doesn't that work?
The first START parameter enclosed in quotes is taken as the Window Title. If you want to give a parameter enclosed in quotes you MUST first provide a title, even an empty one:
for %%i in ("*.xml") do start "" /separate /wait "%PROGRAM_PATH%" "%LOCAL_OUTGOING_PATH%\%%i"
or
for %%i in ("*.xml") do start "Win Title" /separate /wait "%PROGRAM_PATH%" "%LOCAL_OUTGOING_PATH%\%%i"
Type START /? for further details.