Windows 8.1 unable to run batch file without command prompt flashing - windows

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.

Related

how to start wget in cmd with start command and show only progress bar?

I want to download a file with wget portable using start command in cmd, with a batch file, but the window looks bad:
#echo off
start /w wget.exe -q -c --show-progress https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.23-winx64.msi
What should I add to my command, to reduce the window to the size of the progress bar? (and if possible change the black background color and the color of the letters)
The download progress window could be opened with the wanted properties with following command line:
start "Download Progress" /wait %ComSpec% /D /T:fg /C "%SystemRoot%\System32\mode.com CON COLS=80 LINES=1 & wget.exe -q -c --show-progress https://cdn.mysql.com//Downloads/MySQLGUITools/mysql-workbench-community-8.0.23-winx64.msi"
The Windows command processor cmd.exe processing the batch file starts with command start one more command processor referenced with predefined environment variable ComSpec with the options:
/D to disable execution of AutoRun commands from registry,
/T:fg to define the foreground and background color (both 0-9A-F) of the console window,
/C to execute the command line specified next and then close itself.
The options are explained by the usage help output on running cmd /? in an opened command prompt window.
The title for the console window is Download Progress as defined already by start which waits for self-termination of started cmd.exe instance. Run start /? in command prompt window for help on this command.
The command line executed by the started command process first runs command MODE to change the number of columns to 80 and the number of lines to 1, i.e. the additional console window becomes very small. Run mode /? in command prompt window for help on this command.
The small additional console window displays only the progress information of wget.exe which is executed next by the second command processor instance.
See also single line with multiple commands for an explanation of the operator &.

How to make a scheduled task complete when the minimised .bat it's running does?

Currently, I am trying to trigger a second task to run when my first task (which runs a minimised batch file) ends. In the first task, I am running cmd.exewith the arguments /c start "" /min "C:\Custom Scripts\Test.bat" ^& exit. While this does launch the batch file minimised, as well as another cmd window which is open for a split-second, the arguments being immediately executed and then terminating means that the first task "completes" almost immediately after it opens, regardless of how long the batch file/second window continues to run for.
Conversely, if I change the arguments to /c start "" /min /wait "C:\Custom Scripts\Test.bat" ^& exit, then the first command window which launches the batch file will not close until the second minimised window does, and so the task does not complete/stop running until the batch file does. However, this also means that the first window is not minimised, which defeats the purpose of minimising the batch file.
Therefore, how can I run all opened/new windows minimised (or only open for a split-second), as well as making the scheduled task complete only when the batch file it's opening does?

How to hide command prompt windows using ExecDos command

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

How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7

After Windows XP, I always use the trick below to start batch files minimized with Windows Task Manager.
From http://www.pcreview.co.uk/forums/running-bat-files-minimized-scheduler-t2125918.html:
"prequisite: all your batch files have an exit-command to finish the actions off. If you do not exit, you will end with a command prompt blinking.
This is what I keep using:
%comspec% /c start /min "C:\Scripts\Destination_inbound_ftp5.bat"
When you save this in the properties, you will get a follow-up dialogue asking you if you meant all this to be parameters or not. Answer NO and the task will be saved as you would expect.
I also read the Stack Overflow question “start %comspec% /c script.cmd” vs “start cmd /C second.cmd script.cmd”, which made me replace the "%comspec%" statement with "C:\Windows\system32\cmd.exe", but that did not change anything either.
The problem is that now, instead of a minimized running bat file, I end up with just a command prompt, minimized but without any of the batch commands executed. The task scheduler status remains "running" :(
How do I get this done on Windows 8 (64-bit)? Preferrable with old-school batch commands instead of PowerShell (or worse ;p)
The start command needs the leading "" quotes to disable the title feature. Try scheduling this:
%comspec% /c start "" /min "C:\Scripts\Destination_inbound_ftp5.bat" ^& exit
Assuming Windows 8 is the same as Windows 7, an "exit" is only going to exit the batch file (which it is going to do anyway).
You need to add the exit code like this:
Under "Program/Script":
CMD (or command.exe, or %comspec%)
Under "Arguments:
/c start "Title" /min "C:\Scripts\Destination_inbound_ftp5.bat" ^& exit
I didn't like seeing the command window pop up and then disappear so here is another solution from https://ss64.com/vb/run.html ...
First create invisible.vbs with this single line of text:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
Next and finally, launch your cmd or batch file via:
%SystemRoot%\system32\wscript.exe "invisible.vbs" "myscript.cmd" //nologo
Ta da! Scripting of this sort has been built into Windows for a long time. If you're curious, do a web search for "WSH" (windows scripting host). You can even write such scripts in dialect of JavaScript called JScript.
Another possibility: a small freeware program named CMDH, that simply runs the requested orders in background.
For example:
cmdh MyScript.cmd
No need to add "exit" to the script.
Tested working in Windows XP SP3, and there is no reason it should fail on Windows 8.
Here's a solution from https://ss64.com/vb/run.html that will run a batch file in a minimized window. Unlike the other solutions that use the start command with /min, this one will not flash a new window onto your screen or interrupt full-screen activities. It does, however, steal focus. I don't know how to avoid that.
First create a file named run_minimized.vbs with this single line of text:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 2, False
Next, create your Task Scheduler task with an action to start the program wscript.exe with these arguments:
"c:\path\run_minimized.vbs" "c:\path\my script.bat"
Change the paths as necessary to specify the locations of the two files.
There is no simple way to pass arguments from Task Scheduler to the batch file while also preserving spaces and quotation marks, because wscript strips quotation marks from its arguments. The simplest way to handle arguments with spaces would be to put the entire batch file command into the vbs:
CreateObject("Wscript.Shell").Run """c:\path\my script.bat"" ""arg 1"" arg2", 2, False
Note the use of quotation marks. There's one pair of quotation marks " enclosing the entire command string, and a pair of adjacent quote characters "" every place you'd use a normal quotation mark in a command line.
Maybe it's not the same as you mean but if I simply run a .bat file with the scheduler and tick this "Hidden" box on the General tab of the task properties it starts minified.
As already mentioned in foxidrive's answer, the issue is caused by the missing title parameter, which is taken from the first quoted argument string on the command line of the start command, which is the quoted batch file path in your command line. Since there is nothing left to be taken as the command/program to be started, the default cmd.exe is started.
Providing a dummy title (which may even be empty) solves that issue:
%ComSpec% /C start "" /MIN "C:\Scripts\Destination_inbound_ftp5.bat"
However, as mentioned in the help message of start (type start /? into a command prompt window), when the provided command/program is a batch file, the command processor cmd.exe is run with the /K switch, which keeps the command prompt window open:
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.
To prevent that, let us explicitly specify the command processor with the /C switch:
%ComSpec% /C start "" /MIN %ComSpec% /C "C:\Scripts\Destination_inbound_ftp5.bat"
So there is no additional exit command necessary.

how to minimize the command prompt when running a batch script?

anybody know how to minimize the command prompt when running a batch script in Windows 3.11?
in Windows XP, there have a command
start /min start.bat
to minimize the cmd prompt, is it have similiar command in MSDos 6.22?
This little batch code should do what you need.
http://zoombody.com/articles/run-a-batch-script-minimized
The relevant code then needs to be placed at the top of your script:
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized
rem Anything after here will run in a minimized window
Here is more information about "%~dpnx0".
There isn't a command that you can use from a DOS prompt, however you can create a PIF file that points to your batch file, in which you can set the default window position (including minimized).
...I think. It's been a couple of decades.
How to minimize the current command prompt:
Purpose:
Close a command prompt after execution.
Open a new command prompt using the same path.
First open command prompt :
Hold down the [Windows] + [R] keys.
Go to this location:
C:\>cd Users\Admin\Desktop
Next excute:
C:\Users\Admin\Desktop>start /min && exit
Results:
A new minimized command prompt should open with the same path.
Alternatively:
Create a script named minimize.bat and type start /min && exit into the script and place it in your system32 folder. In order to have the ability to access it via the command prompt.
Windows 10 makes it very easy to start minimized. Simply create a shortcut and click properties. On the shortcut tab half way down is the "Run:" option witch lets you select how you want the command line window to start up. Just select minimized and your command window will remain minimized from the onset.
Windows10 properties window of a shortcut
Use WinExec to start your batch file and pass SW_SHOWMINIMIZED for the second parameter.
See also, How do I run a batch file with WinExec?

Resources