How to start an application without waiting in a batch file? - windows

Is there any way to execute an application without waiting in batch file? I have tried the start command but it just creates a new command window.

I'm making a guess here, but your start invocation probably looks like this:
start "\Foo\Bar\Path with spaces in it\program.exe"
This will open a new console window, using “\Foo\Bar\Path with spaces in it\program.exe” as its title.
If you use start with something that is (or needs to be) surrounded by quotes, you need to put empty quotes as the first argument:
start "" "\Foo\Bar\Path with spaces in it\program.exe"
This is because start interprets the first quoted argument it finds as the window title for a new console window.

I used start /b for this instead of just start and it ran without a window for each command, so there was no waiting.

If your exe takes arguments,
start MyApp.exe -arg1 -arg2

If start can't find what it's looking for, it does what you describe.
Since what you're doing should work, it's very likely you're leaving out some quotes (or putting extras in).

EDIT moved /B parameter/switch to before the command path, as per Nime Cloud's recommendation
I successfully used a combo of #joey's post, with added /B flag, as follows
START "" /B "Path\To\Application.exe"
Partial output from help command: HELP START...
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.

This command starts ClamAV in a seperate console window with custom icon of clamd.exe
start "c:\clamav\clamd.exe" "c:\clamav\clamd.exe"
So the generic format would be like:
start "Your new title" "c:\path\your.exe"

Related

Run Multiple .exe Files from a Batch File Simultaneously and Silently

I am on windows 10 and i need to run multiple executable files from a batch file silently, without waiting for them to finish. at the moment i have:
#echo off
start "" "%~dp0executable.exe" /q
start "" "%~dp0executable2.exe" /q
but this still opens multiple console windows.
any workarounds that achieve the same results are welcome.
Your executables seem to be console applications, otherwise no console window would appear.
Anyway, the start command features an option /B; here is an excerpt of the output of start /?:
B Start application without creating a new window. The
application has ^C handling ignored. Unless the application
enables ^C processing, ^Break is the only way to interrupt
the application.
By ^C and ^Break, pressing Ctrl + C and Ctrl + Pause/Break is meant, respectively.
In case you have a third .exe that needs to wait after the first two started simultaneously you can also use the start /w argument for the second one and call the third like so:
#echo off
start /B "%~dp0executable.exe"
start /W "%~dp0executable2.exe"
call "%~dp0executable3.exe"

How to launch this program from the command line?

This is the program I am trying to launch from command line (Star Guard)
I opened a new command prompt process in this directory and am trying to start the Star Guard application with command line(so I can pass in command line arguments later).
However when I do so, I don't end up launching the program but I do end up launching a new command prompt process in the same directory.(output shown below) The program launches fine when I start it normally(GUI click)
Does anyone know what the issue is? I first did the ls(OSx) equivalent in Windows to make sure I had the right file path for the executable. I then used the start command to start the program along with enclosing the executable path in quotation marks to account of the spaces.
The syntax of the start command is unique, not to mention daft. If the first argument is in quotes it is interpreted as a window title.
In this case, you don't actually need to use start at all, you could just say
"Star Guard"
or
"Star Guard.exe"
If you want to use start, perhaps because you want to specify /wait for a GUI application or because you want to launch a console application in a new window, you have to include the title argument:
start "" "Star Guard.exe"
(The title argument doesn't need to actually specify a title, it just needs to be present.)
From OS/2 Warp Help
Starts an OS/2 program in another session.
The primary use for START is to automatically start programs at system startup. The
special batch file, STARTUP.CMD, allows you to do this.
To imbed redirectional signals into the command session, enclose the command and
command inputs in quotation marks.
START
"program /K /F
title" /C /B
/N
/PGM /FS /MAX
/WIN /MIN
/PM
/DOS
command
/I command
inputs
Related Commands: RUN
Enter this command without a parameter to start an OS/2 command processor.
If you use the /WIN, /FS, or /PM parameter, your program runs in the foreground session.
If you do not use one of these parameters, you can use the /F parameter to make the
program run in the foreground session.
Make sure that you specify the correct drive and path when you use the START command to
run a batch file with the STARTUP.CMD file. Also, if you plan to redirect I/O using the
START command, enclose the command and command inputs within quotation marks.
You can use START to run full-screen applications or applications running in a window
such as Presentation Manager programs.
START determines the type of application and will run it in the appropriate window or
full-screen session. However, you have the option to override the determined default by
using the /FS, /WIN, /PM, or /I parameter.
You cannot start a batch file (.CMD) with the /PM parameter.

Why can't I start programs in the command line without /d? (Windows 7x64)

I am trying to create a batch script that opens a program. I am doing some testing and I can't figure this out:
If I run CMD.exe and input start /d "C:\wamp" wampmanager.exe the program opens
but
If I run CMD.exe and input start "C:\wamp\wampmanager.exe" I get "the current directory is invalid"
Now when I try to do start runas /profile /user:Administrator "C:\wamp\wampmanager.exe" I get prompted for Administrator's password, but nothing happens when I enter it.
Can someone please tell me how I can run the above command?
Because the start program's syntax expect the window title as its first quoted argument.
(see start /?). You can supply an empty string, however:
start "" "C:\wamp\wampmanager.exe"
or, if you don't need quotes to mask parts of the path, just leave them out altogether:
start C:\wamp\wampmanager.exe
start "some-text"
starts a new command window with "some-text" as the title of the window. To start a program, do not use the quotes around the argument
start program-name

problem reading args from batch script

On windows, I'm trying to acquire the file name using the %~f1 parameter.
I'm doing this from a new voice (command) which I've added to the contextual menu.
In the windows registry, the voice simply calls a batch script which prints the file name,
by this way:
`C:\script.bat %~f1`
but I get this output:
`C:\Documents and Settings\Administrator\Desktop\%~f1`
so, the path is ok, but what about the filename?!
Suggestions? Thanks!
When the context menu item it triggered, it is done so by Explorer (not cmd.exe) and Explorer does not implement %~f1. Hence you get the current result.
What you need is to modify your script so it receives the whole filename (you would probably put only 'C:\script.bat %1' or 'C:\script.bat' in the registry) and update your script to use %~f1:
#echo first argument: %1
#echo filename only: %~f1
#notepad %~f1
Good luck with that!
Try enclosing the entire variable in %'s.
C:\script.bat %~f1%

How to create batch file in Windows using "start" with a path and command with spaces

I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.
However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?
E.g. batch file
start "c:\path with spaces\app.exe" param1 "param with spaces"
Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:
start "" "c:\path with spaces\app.exe" param1 "param with spaces"
You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.
Escaping the path with apostrophes is correct, but the start command takes a parameter containing the title of the new window. This parameter is detected by the surrounding apostrophes, so your application is not executed.
Try something like this:
start "Dummy Title" "c:\path with spaces\app.exe" param1 "param with spaces"
start "" "c:\path with spaces\app.exe" "C:\path parameter\param.exe"
When I used above suggestion, I've got:
'c:\path' is not recognized a an internal or external command, operable program or batch file.
I think second qoutation mark prevent command to run. After some search below solution save my day:
start "" CALL "c:\path with spaces\app.exe" "C:\path parameter\param.exe"
Interestingly, it seems that in Windows Embedded Compact 7, you cannot specify a title string. The first parameter has to be the command or program.
You are to use something like this:
start /d C:\Windows\System32\calc.exe
start /d "C:\Program Files\Mozilla
Firefox" firefox.exe start /d
"C:\Program Files\Microsoft
Office\Office12" EXCEL.EXE
Also I advice you to use special batch files editor - Dr.Batcher
Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.
I researched successfully and it is working fine for me. My requirement is to sent an email using vbscript which needs to be call from a batch file in windows. Here is the exact command I am using with no errors.
START C:\Windows\System32\cscript.exe "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"

Resources