How to hide command prompt windows using ExecDos command - windows

I want to execute three bat files in my script, the problem is when i run these .bat files directly using execwait, command windows gets open, I want to hide these command windows but its not working. My code is of just 3 lines.
ExecDos::exec '"catalina_start.bat"'
ExecDos::exec '"mysql_start.bat"'
ExecDos::exec '"apache_start.bat"'
I also tried this nsExec command but still no solution:
nsExec::Exec "cmd /C catalina_start.bat"
nsExec::Exec "cmd /C mysql_start.bat"
nsExec::Exec "cmd /C apache_start.bat"
A little background on these .bat files, Actually these are files of xampp setup, xampp internally uses these files to start tomcat, mysql, and apache.
The problem I am facing is that only first bat file gets executed, i. e. tomcat gets started (I can see that in xampp console), but then script dosen't move ahead, sql and apache is not getting started.

Does the batch-file contain pause or something else that prevents it from completing?
You should start off just by using something like ExecWait '"cmd.exe" /k "$InstDir\catalina_start.bat"' (or /c) so you can see the text written to the console including any errors. Once it works correctly you can switch to one of the exec plugins that hides the console...

You can change command windows from cmd /C catalina_start.bat to start /Min cmd /c catalina_start.bat it will hide command windows

Related

Getting a Windows batch file to execute an application in background and then execute the next statement

I am having issue trying to get my Windows batch file to launch the Jetty web server in the background and then launch IE. The current behavior is that after it started my Jetty web server, it doesn't return to launch IE. It simply stuck there until I terminate the web server and then batch script will then proceed and launch IE.
Here's my batch script
SET JAVA_HOME=".\openjdk-1.8.0.141"
SET JETTY_HOME=".\jetty-distribution-9.4.6.v20170531"
start /B cd /d "%~dp0" & %JAVA_HOME%\bin\javaw -DSTOP.PORT=8081 -DSTOP.KEY=stop_jetty -Djetty.base=%JETTY_HOME% -jar %JETTY_HOME%\start.jar
"C:\Program Files\Internet Explorer\iexplore.exe" http://localhost:8080/foo-tools
Can you spot anything obvious here? I already used the 'start /B' to attempt to launch it in the background. I have to change directory back to the current working directory, otherwise the variable that I set will not work.
Thanks in advance!
Why not simplify things and stipulate the script path with the START's /D <Path> parameter?
SET "JAVA_HOME=openjdk-1.8.0.141"
SET "JETTY_HOME=jetty-distribution-9.4.6.v20170531"
START "" /D "%~dp0" "%JAVA_HOME%\bin\javaw" -DSTOP.PORT=8081 -DSTOP.KEY=stop_jetty -Djetty.base="%JETTY_HOME%" -jar "%JETTY_HOME%\start.jar"
START "" "%PROGRAMFILES%\Internet Explorer\iexplore.exe" http://localhost:8080/foo-tools
I missed off START's /B parameter because it was my understanding that javaw.exe doesn't open a CMD window anyhow. If my understanding is incorrect then please add it back just before "%JAVA_HOME%.
The START command for IE is only really necessary if you need the script again or don't want the cmd window to remain open.

Windows 8.1 unable to run batch file without command prompt flashing

I have scheduled a task to run a batch file, and currently every time the task executes, there is a command prompt box that flashes. This is very undesirable. The node.js command prompt window executes minimized correctly, it is the windows command prompt that flashes.
Here is the action that the scheduled task runs:
cmd /min /c "C:\Users\computeruser\Building Intelligence\javadobe\runCheck.bat"
and here is the contents of the batch file, (probably unnecessary to show, but I was originally trying to run these commands straight from the task scheduler. Putting them in this batch file instead has got me closest to what I actually want to happen: run a javascript file with node.js minimized):
cd "C:\Program Files (x86)\BuildingIntelligence\javadobe\" & START /MIN node index.js /exit
A list of the commands I've tried:
cmd.exe /c start /min "C:\Users\computeruser\Building Intelligence\javadobe\runCheck.bat"
cmd.exe /c start /min "C:\Users\computeruser\Building Intelligence\javadobe\runCheck.bat" & /exit
%comspec% /c start "" /min "C:\Users\computeruser\Building Intelligence\javadobe\runCheck.bat"
all of these commands leave the command prompt box open, not closing it but minimizing it after it opens. There is also a notification that says "not enough storage is available to process this command".
I need to run this task with the highest privileges, and while it needs to be invisible most of the time, it needs to be able to show a dialog box occasionally when the task is run.
Thanks in advance for any help!
Basically, if what you have tried doesn't work, you're going to need a third party tool. NirCMD should do it and it's freeware.
NirCMD exec hide "C:\Users\computeruser\Building Intelligence\javadobe\runCheck.bat"
At the bottom of this page there is a link for the download. This page covers what the tool is capable of.

Command to start a process in the background and run silently

I'm trying to write a command in a bat file to run an installer exe file. The important part is to start and run the installer in silent mode. To clarify, I DO NOT want the user to see the installer and click through the wizard. They should just be able to double click the bat file and walk away. I have attempted this command in my bat file:
#echo off
REM Next command runs installer in silent mode
start /d "%USERPROFILE%\Desktop" MyInstaller_7.1.51.14.exe –s –v –qn
The –s –v –qn are supposed to enable the installer to run in the background, but they are not working.
Can anyone help me improve my command in my bat file so that MyInstaller_7.1.51.14.exe is indeed running in the background, silently, with no UI or wizard of any kind visible to the user??
Please help.
You can try one of these START command options to see if it gives you the effect you want:
/B = Start application without creating a new window
/MIN = Start window minimized
Edited:
Try putting the command with its switches inside quotes:
start /d "%USERPROFILE%\Desktop" "MyInstaller_7.1.51.14.exe –s –v –qn"
Another solution you can test :
Create a file RunHide.vbs and put this line in it :
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
and then run your batch file like this :
wscript.exe "RunHide.vbs" "Install.bat"
and your batch file will be run without any windows (and maybe your Installer to)
I finally figured it out.
Here is the correct code:
#echo off
REM Next command runs installer in silent mode
start "%USERPROFILE%\Desktop" MyInstaller_7.1.51.14.exe /s /v /qn
The change was between –s –v –qn and /s /v /qn where the former does not work, and the latter does.

Scripting environment setup in windows

When I start my day programming (using windows 7), I have a bunch of windows I'd like open and ready:
command prompt in my code directory running the DevNull smtp java server
command prompt in the tomcat\bin directory with startup.bat running after rmdir /S /Q'ing work and test webapp directories
IntelliJ running
after tomcat loads (fine with just having a timer), Firefox with my webapp loaded
after tomcat loads, Chrome with my webapp loaded
Those are pretty core... then it depends on what exactly I'm working on as far as other apps I need open.
So how do I write a script I can double click on and have all the above ready for me, saving me a couple minutes each day and a little less annoying getting started? I know about .bat files, is it easy to do the above with a .bat file? Is there a nice app that can easily do the above for me?
It is pretty straight-forward to put all of that in a bat file, something like this:
#echo off
rmdir /S /Q testdir
rmdir /S /Q workdir
start cmd /K c:\foo\bar.bat
start cmd /K c:\foo\bas.bat
start firefox.exe "http://www.stackoverflow.com/"
You can put all that into a batch file, and use the sleep command from the Windows Server 2003 Resource Kit Tools.

Hide CMD window after using START to run a network application

I have an application that is run over a network. I need to be able to run this application from a batch file, and had ended up using this:
pushd \\server\folder
start /wait program.exe
Aside from the message saying...
\\server\folder
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
...it works fine, but the CMD window lingers. I know that /wait is the cause, but it appears that I can only get the program to run successfully if I use /wait. If I remove /wait, then I get bizarre errors from the program about not being able to start successfully.
What else might there be that I can try?
If you want to hide the program while it runs, you can also use the /MIN param, to have it start minimized.
Try:
start /b /wait program.exe

Resources