When i run this batch file command as a single batch file the second command does not run.However when i run them as individual batch file commands they work fine.
"C:\Program Files\Mozilla Firefox\firefox.exe" -P "america" -no-remote http://hakikahost.com/error.html
"nircmd.exe" win hide process "firefox.exe"
tried creating 1 single batch file which called with a call the two batch files now having separated the batch files command separately like this
call test.bat
call hide.bat
where test.bat contained the first command and hide.bat contained the second command but it still didnt work.What am i doing wrong?
It may be that firefox.exe never returns until you close the window. Try using start to launch the applications, as start will return as soon as the application has launched.
start "" "C:\Program Files\Mozilla Firefox\firefox.exe" -P "america" -no-remote http://hakikahost.com/error.html
start "" "nircmd.exe" win hide process "firefox.exe"
The first command, "C:\Program Files\Mozilla Firefox\firefox.exe" does not return until the Fx session has ended (ie you EXIT from it)
Then there are no Fx executables so the second command can't hide the process that doesn't exist.
Try
START "" "C:\Program Files\Mozilla Firefox\firefox.exe" -P "america" -no-remote http://hakikahost.com error.html
"nircmd.exe" win hide process "firefox.exe"
The only difference is the START "" before the firefox-invocation. Note that the empty-quoted-string is required - you could enter a string between the quotes if you like - this becomes the window title.
Related
in Windows 7 x64 SP1 I need to create a batch file (.bat) which keeps the cmd.exe console window open and has a specific title:
#ECHO OFF
title notepadtest
#ECHO ON
start "" /WAIT notepad
But this batch file keeps opening an infinite number of cmd.exe console windows in an unstoppable loop!
How can I create a batch file (.bat) which creates only ONE cmd.exe console window and keeps it open and has a specific title?
Please ensure that your batchfile is not named notepad.cmd or notepad.bat or anything like any system or external command. Name it something like mynotepad.cmd instead., then try this one please:
#echo off
title notepadtest
start "" /w notepad.exe
cmdline and batch files typically works like this. When a command is issued, it first checks the local path, where the script was launched from for the command, if not found, it will check your environment and system environment. So if you name a batchfile notepad.bat your batch is actually starting itself over and over, instead of finding notepad.exe in the environment variables.
Always name batch files something unique and not system/external command related.
Always use full executable name in a batch, like start "" /w notepad.exe and not start "" /w notepad
I created a startup bat file that looks like this
taskkill /im RemoteDesktopManager.exe
C:\Users\kheradmand\AppData\Local\Google\Chrome\Application\chrome.exe
"C:\Program Files (x86)\JetBrains\PhpStorm 7.1.2\bin\PhpStorm.exe"
"C:\Program Files\Mozilla Firefox\firefox.exe"
it does the first and second, but won't go any further, they all exist
how can I fix this?
update : I tried suggestion provided by #phd443322 and wrote this:
taskkill /im RemoteDesktopManager.exe
start "" /w C:\Users\kheradmand\AppData\Local\Google\Chrome\Application\chrome.exe
start "" /w "C:\Program Files (x86)\JetBrains\PhpStorm 7.1.2\bin\PhpStorm.exe"
start "" /w "C:\Program Files\Mozilla Firefox\firefox.exe"
intrestingly each command still waits for that program to be closed to continue to the next.
so why still not working?
Below there is a working Batch file, as first advised by phd443322:
taskkill /im RemoteDesktopManager.exe
start "" C:\Users\kheradmand\AppData\Local\Google\Chrome\Application\chrome.exe
start "" "C:\Program Files (x86)\JetBrains\PhpStorm 7.1.2\bin\PhpStorm.exe"
start "" "C:\Program Files\Mozilla Firefox\firefox.exe"
Batch files wait for programs to exit unlike interactive. These are the rules documented in the Start command.
If Command Extensions are enabled, external command invocation
through the command line or the START command changes as follows:
non-executable files may be invoked through their file association just
by typing the name of the file as a command. (e.g. WORD.DOC would
launch the application associated with the .DOC file extension).
See the ASSOC and FTYPE commands for how to create these
associations from within a command script.
When executing an application that is a 32-bit GUI application, CMD.EXE
does not wait for the application to terminate before returning to
the command prompt. This new behavior does NOT occur if executing
within a command script.
When executing a command line whose first token is the string "CMD "
without an extension or path qualifier, then "CMD" is replaced with
the value of the COMSPEC variable. This prevents picking up CMD.EXE
from the current directory.
When executing a command line whose first token does NOT contain an
extension, then CMD.EXE uses the value of the PATHEXT
environment variable to determine which extensions to look for
and in what order. The default value for the PATHEXT variable
is:
.COM;.EXE;.BAT;.CMD
Notice the syntax is the same as the PATH variable, with
semicolons separating the different elements.
When searching for an executable, if there is no match on any extension,
then looks to see if the name matches a directory name. If it does, the
START command launches the Explorer on that path. If done from the
command line, it is the equivalent to doing a CD /D to that path.
#ECHO OFF
title Skype secondary Instance
echo A second instance of Skype will be started.
pause
"C:\Program Files\Skype\Phone\Skype.exe" /secondary
exit
After running this BAT script the command windows does not close until the Skype program is not closed. Could you tell me why? And how to close the command window after the program has started.
Use the START command.
start "" "C:\Program Files\Skype\Phone\Skype.exe" /secondary
Although, I should think you don't even need a batch file. You could simply create a shortcut with "C:\Program Files\Skype\Phone\Skype.exe" /secondary as the target.
I tried this command from the cmd prompt:
start "c:\program files (x86)\google\chrome\application\chrome.exe" --new-window "http://localhost:8080:/debug?port=5858"
and I get "windows can not find '--new-window'
If I remove the start command, it works fine. If I leave the start command but remove the --new-window parm then the url is opened in my default browser (ie).
I've tried several variations of the above but can't get it to work.
What is the correct syntax for the start command to open chrome with the given url in a new window?
Answer is there : Using the "start" command with parameters passed to the started program
start "" "c:\program files (x86)\google\chrome\application\chrome.exe" --new-window "http://localhost:8080:/debug?port=5858"
(add empty title parameter at the beginning of the line)
In Windows 10, following command works:
start chrome --new-window "https://www.facebook.com"
This works perfectly in cmd.
Try to put this in a batchfile, then you can play with size and position to:
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window "http://brianp.dk/" --window-size="2560,1000" --window-position="0,0" --user-data-dir="D:/Test/Profiles/1"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window "http://borsen.dk/" --start-maximized --window-position="2560,000" --user-data-dir="D:/Test/Profiles/2"
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --new-window "http://penge.dk/" --window-size="1280,1000" --window-position="0000,1000" --user-data-dir="D:/Test/Profiles/3"
I have a batch file that starts an app with a lot of command-line parameters:
"C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe" /port:1672 /path:"C:\Code.Net\My App\Iteration 6\REL_6.8.806_PerfEnhanceV\Fusion\Code\CC.Fusion\CC.Fusion.Services" /vpath:"/FusionServices"
The problem is that when I run the batch file, the DOS window stays up until the command completes and I would like it to go away. So I tried using the start command, but placing it in front, like this:
start "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\11.0\WebDev.WebServer40.exe" /port:1672 /path:"C:\Code.Net\My App\Iteration 6\REL_6.8.806_PerfEnhanceV\Fusion\Code\CC.Fusion\CC.Fusion.Services" /vpath:"/FusionServices"
But I get an error stating that Invalid switch - "/port:1672"
I have also tried escaping the double quotes, but I was not successful.
How do I fix that?
An extra pair of rabbits' ears should do the trick.
start "" "C:\Program...
START regards the first quoted parameter as the window-title, unless it's the only parameter - and any switches up until the executable name are regarded as START switches.
I think this other Stack Overflow answer would solve your problem: How do I run a bat file in the background from another bat file?
Basically, you use the /B and /C options:
START /B CMD /C CALL "foo.bat" [args [...]] >NUL 2>&1