Many times systems engineers come across the need to suppress the console window of a cmd prompt while setting up various batch and script automations to be run in silent mode.
Below is the list of various options available to control the cmd console window and you need to choose the option as per your requirements:
- Hidden Start (a complete solution to control console windows and also supports x64bit)
- Start (helps control spawned process console)
- PowerShell –WindowStyle Hidden
- WshShell.Run WindowStyle = 0
- Javaw.exe is a console/window less Java.exe that runs Java programs as hidden process
—————————
Hidden Start v3.2 (64-bit)
—————————
Run from command line:
hstart64.exe /[PARAMETERS] /[PRIORITY] [COMMAND LINES]
PARAMETERS:
/NOCONSOLE – start console applications without any windows
/ELEVATED or /RUNAS – start applications in elevated mode (Vista)
/NONELEVATED – start applications in non-elevated mode (Vista)
/UAC – run Hstart executable in elevated mode (Vista)
/SHELL – run apps, open docs and URLs in the Windows Shell
/D=PATH – set the starting directory for executed applications
/DELAY=N – delay N seconds before command execution
/WAIT – wait for the application to terminate (run synchronously)
/WAITINPUT – wait for the user input to set the priority class
/MSG=TEXT – show the message after command execution
/TITLE=TEXT – set the title of the message
/ERRMSG=TEXT – show the error message if an error detected
/ERRTITLE=TEXT – set the title of the error message
/SILENT – silent mode, no error messages will be displayed
/TEST – test mode, see what parameters are passed to Hstart
PRIORITY classes:
/[HIGH | ABOVENORMAL | NORMAL | BELOWNORMAL | IDLE]
Don’t forget about quotes when using complex COMMAND LINES:
hstart64.exe /NOCONSOLE /D=»C:Dir 1″ «»C:Dir 2test.bat» -param»
—————————
OK
—————————
C:>start /?
Starts a separate window to run a specified program or command.
START [«title»] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
[/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
[parameters]
«title» Title to display in window title bar.
path Starting directory.
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.
I The new environment will be the original environment passed
to the cmd.exe and not the current environment.
MIN Start window minimized.
MAX Start window maximized.
SEPARATE Start 16-bit Windows program in separate memory space.
SHARED Start 16-bit Windows program in shared memory space.
LOW Start application in the IDLE priority class.
NORMAL Start application in the NORMAL priority class.
HIGH Start application in the HIGH priority class.
REALTIME Start application in the REALTIME priority class.
ABOVENORMAL Start application in the ABOVENORMAL priority class.
BELOWNORMAL Start application in the BELOWNORMAL priority class.
AFFINITY The new application will have the specified processor
affinity mask, expressed as a hexadecimal number.
WAIT Start application and wait for it to terminate.
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.
parameters These are the parameters passed to the command/program.
NOTE: The SEPARATE and SHARED options are not supported on 64-bit platforms.
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.
C:>
C:>powershell /?
PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
[-NoLogo] [-NoExit] [-Sta] [-NoProfile] [-NonInteractive]
[-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
[-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
[-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
[-Command { – | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]
PowerShell[.exe] -Help | -? | /?
-PSConsoleFile
Loads the specified Windows PowerShell console file. To create a console
file, use Export-Console in Windows PowerShell.
-Version
Starts the specified version of Windows PowerShell.
-NoLogo
Hides the copyright banner at startup.
-NoExit
Does not exit after running startup commands.
-Sta
Start the shell using a single-threaded apartment.
-NoProfile
Does not use the user profile.
-NonInteractive
Does not present an interactive prompt to the user.
-InputFormat
Describes the format of data sent to Windows PowerShell. Valid values are
«Text» (text strings) or «XML» (serialized CLIXML format).
-OutputFormat
Determines how output from Windows PowerShell is formatted. Valid values
are «Text» (text strings) or «XML» (serialized CLIXML format).
-WindowStyle
Sets the window style to Normal, Minimized, Maximized or Hidden.
-EncodedCommand
Accepts a base-64-encoded string version of a command. Use this parameter
to submit commands to Windows PowerShell that require complex quotation
marks or curly braces.
-File
Execute a script file.
-ExecutionPolicy
Sets the default execution policy for the session.
-Command
Executes the specified commands (and any parameters) as though they were
typed at the Windows PowerShell command prompt, and then exits, unless
NoExit is specified. The value of Command can be «-«, a string. or a
script block.
If the value of Command is «-«, the command text is read from standard
input.
If the value of Command is a script block, the script block must be enclosed
in braces ({}). You can specify a script block only when running PowerShell.exe
in Windows PowerShell. The results of the script block are returned to the
parent shell as deserialized XML objects, not live objects.
If the value of Command is a string, Command must be the last parameter
in the command , because any characters typed after the command are
interpreted as the command arguments.
To write a string that runs a Windows PowerShell command, use the format:
&
quot;& {<command>}»
where the quotation marks indicate a string and the invoke operator (&)
causes the command to be executed.
-Help, -?, /?
Shows this message. If you are typing a PowerShell.exe command in Windows
PowerShell, prepend the command parameters with a hyphen (-), not a forward
slash (/). You can use either a hyphen or forward slash in Cmd.exe.
EXAMPLES
PowerShell -PSConsoleFile SqlSnapIn.Psc1
PowerShell -version 1.0 -NoLogo -InputFormat text -OutputFormat XML
PowerShell -Command {Get-EventLog -LogName security}
PowerShell -Command «& {Get-EventLog -LogName security}»
# To use the -EncodedCommand parameter:
$command = ‘dir «c:program files» ‘
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
powershell.exe -encodedCommand $encodedCommand
C:>
InvokeHiddenProcess.vbs
C:>type InvokeHiddenProcess.vbs
Set WshShell = WScript.CreateObject(«WScript.Shell»)
cmd = «cmd /k Test.bat»
Return = WshShell.Run(cmd, 0, True)
set WshShell = Nothing
C:>
C:>type Test.bat
echo «helloo» > testing.txt
C:>type testing.txt
«helloo»
C:>
Javaw.exe
javaw [ options ] class [ argument … ]
javaw [ options ] -jar file.jar [ argument … ]
options
Command-line options.
class
Name of the class to be invoked.
file.jar
Name of the jar file to be invoked. Used only with -jar.
argument
Argument passed to the main function.
For more detailed arguments list refer to Sun Java’s Javaw – the Java application launcher.
If you like programming shell scripts for Windows, you might want to run your command prompt scripts in the background silently without actually opening the command prompt windows. This easily possible with a few lines of vbscript.
Why Run It Silently?
A silent prompt is great for scheduled tasks that won’t annoy you with a prompt or even prevent you from running 3D applications such as games. It’s also a great way for administrators to run some tasks in the background or hide activity regular users are not supposed to see. There are a bunch of reasons why they are necessary at times.
Using VBScript To Run CMD Script Silently
Here’s a little snippet of one of my command prompt scripts:
rundll32.exe %SystemRoot%\system32\shell32.dll,Control_RunDLL %SystemRoot%\system32\desk.cpl desk,@Themes /Action:OpenTheme /file:"C:\Windows\Resources\Themes\landscapes.theme"
Let’s say you don’t want Windows 7 to open a command prompt window and run it silently, you can write a vbscript for that:
1. Step Open a notepad editor
2. Step Insert the following code:
Set WshShell = CreateObject("WScript.Shell")
cmds=WshShell.RUN("E:\scripts/themescript.bat", 0, True)
Set WshShell = Nothing
The 0 makes the shell script run silently.
3. Step Save your notepad file. When you save it add the extension .vbs and select All files from the dropdown as seen below:
4. Step You can now schedule that cmd script and it will not open a command prompt window
This is very handy if you don’t want to be annoyed with dozens of command prompt windows when your scheduled tasks are running.
You might also want to know how to open the command prompt in Windows 8
There are a few ways to run a batch file silently, depending on your needs.
If you just need to run the batch file quietly in the background without any visible window, you can use the Windows Task Scheduler. Create a new task, give it a name and description, and set the task to run whether the user is logged on or not. Then, under the Triggers tab, create a new trigger and set it to run the task Daily or Weekly at a time when you know the computer will be turned on. Finally, under the Actions tab, add a new action and browse to the location of your batch file.
If you need to run the batch file and have it interact with other programs or files, you can use the Windows Script Host. To do this, open Notepad and type the following:
Set WshShell = WScript.CreateObject(«WScript.Shell«)
WshShell.Run ««»» & WScript.Arguments(0) & ««»», 0, False
Save the file as a .vbs file and then double-click it to run it. When you run the .vbs file, you can specify the batch file as a parameter
How do I make a batch file run silently?
How do I run CMD EXE silently?
There are a few ways to run CMD EXE silently:
1. Use the /S switch: This will tell CMD EXE to run silently, without displaying any window.
2. Use the /Q switch: This will tell CMD EXE to run quietly, without displaying any window or message.
3. Use the /D switch: This will tell CMD EXE to run in debug mode. This will disable all input and output, so CMD EXE will not display any window or message.
4. Use the /T switch: This will tell CMD EXE to run in test mode. This will disable all input and output, so CMD EXE will not display any window or message.
How do I run a batch file that is hidden?
There are a few ways to run a batch file that is hidden. One way is to use the Command Prompt. To do this, open the Command Prompt and type in «cmd /c start /min /wait «. This will run the batch file in a minimized window. Another way is to use the Windows Scheduler. To do this, open the Scheduler and create a new task. In the task, browse to the batch file and select it. Then, in the task settings, select «Run whether user is logged on or not» and «Hidden«.
How do I run a batch file without opening CMD?
There are a few ways to run a batch file without opening CMD. One way is to use the Windows Task Scheduler. You can schedule a task to run a batch file at a specific time or interval. Another way is to use a third-party software like Batchrun. Batchrun lets you create a batch file without having to write any code. You can simply drag and drop your commands into the software.
How do I run a batch file in the background?
There are a few ways to run a batch file in the background:
1. Use the start command. For example, to run a batch file named «MyBatchFile.bat» in the background, you would use the following command:
start /b MyBatchFile.bat
2. Use the call command. For example, to run a batch file named «MyBatchFile.bat» in the background, you would use the following command:
call MyBatchFile.bat
3. Use the PowerShell Start-Process cmdlet. For example, to run a batch file named «MyBatchFile.bat» in the background, you would use the following command:
Start-Process -NoNewWindow -FilePath «MyBatchFile.bat«
4. Use the Task Scheduler. For example, to run a batch file named «MyBatchFile.bat» in the background, you would use the following command:
schtasks /create /tn «My Task» /tr «MyBatchFile.bat» /sc ONCE /st 00:00
What does @echo off do?
The @echo off command tells the Command Prompt to not display the commands that are being executed. This can be useful if you want to hide what you are doing from other people who are using the same computer.
Can you run an exe silently?
Yes, you can run an exe silently by using the command line argument /silent.
What is quiet mode cmd?
Quiet mode is a setting that can be applied to many command-line programs that tells the program to run without printing any output. This can be useful if you want to run a program without any visual output, or if you want to suppress any error messages that the program might generate.
How do I run a command prompt in the background?
There are a few ways to run a command prompt in the background. One way is to use the «start» command. For example, if you wanted to run the command «ping google.com» in the background, you would use the following command:
start /b ping google.com
Another way to run a command prompt in the background is to use the «cmd» command. For example, if you wanted to run the command «ping google.com» in the background, you would use the following command:
cmd /c start /b ping google.com
You can also use the «tasklist» command to view all the tasks that are running in the background.
How do I run a batch file locally?
To run a batch file locally, you will need to open the Command Prompt application. Once the Command Prompt is open, you will need to navigate to the folder that contains the batch file. To do this, you will use the «cd» command. Once you are in the correct folder, you will need to type in the name of the batch file and hit enter. The batch file will then run.
Can I run a shell script in background?
Yes, you can run a shell script in the background by using the & operator. For example, if you have a script called myscript.sh, you can run it in the background by typing ./myscript.sh &.
How do I run a running script in the background?
There are a few ways to run a running script in the background. One way is to use the «nohup» command. This will allow the script to continue running even after you close the terminal window. Another way is to use the «screen» command. This will create a new terminal session that you can detached from and reconnect to later.
How do I run a process in the background in CMD?
To run a process in the background in CMD, you will need to use the «start» command. For example, if you wanted to run the «notepad» program in the background, you would type «start notepad» at the CMD prompt.
What does @echo do in a batch file?
The @echo command is used in a batch file to display a message on the screen. The message can be anything you want, and it will be displayed on the screen when the batch file is run.
Batch files are a type of files that are good for doing a bunch of computing tasks on the Windows operating system. They can perform multiple commands at once and are great for anyone who writes code, needs to automate things on Windows, etc. In most cases, a batch file will run in a Command Prompt window session. Some people find this CMD window sometimes unnecessary and annoying.
This guide will show you how to run those batch files quietly in the background without showing any CMD window on Windows 11 or 10.
Option 1: Run batch files from task scheduler
Windows Task Scheduler is a tool that lets you set up tasks to run on their own. You can use it to run batch files without showing any window, keeping them out of your way.
Also see: How to Hide System Tray Icons in Windows 11
To set up a silent batch file run in Task Scheduler on Windows 11 or 10, do this:
- Start by opening Task Scheduler from the Start Menu.
- Click “Create Task” on the right side.
- Name and describe your task in the “General” tab.
- Choose “Run whether user is logged on or not” to let it run anytime.
- Tick “Run with highest privileges” if it needs admin rights.
- Don’t forget to check “Hidden“.
- In “Triggers“, pick when the task should start.
- Under “Actions“, hit “New” to add a new action.
- Select “Start a program” and find your batch file.
- Hit OK to save your setup.
After setting it up, your task will run your batch file at the chosen time or event, all without popping up a window. You can check how it went by looking at the task’s history in Task Scheduler.
Suggested tip: How to Hide Apps in Windows 11
Option 2: Create a VBS script
Visual Basic Script (VBS) lets you write little programs that work with Windows. You can make a VBS script to run your batch file quietly in the background. The script uses a WScript.Shell
object to start your batch file without showing the command prompt window.
Here’s how a VBS script to run a batch file invisibly might look:
Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "C:\PathToYour\BatchFile.bat" & Chr(34), 0 Set WshShell = Nothing
Save it with a .VBS extension and open it to run your batch file without any window appearing.
This script makes a WScript.Shell
object, runs your batch file hidden with the Run
method, and then cleans up after itself.
Option 3: Turn batch files into apps
You can change your batch file into an app (.exe) that works just like any other program. This way, you don’t need to open a command prompt window or use extra tools to run your batch file. There are many tools out there that can do this for you, like Bat To Exe Converter, Advanced BAT to EXE Converter, or Quick Batch File Compiler.
Related: How to check how much time you spend on apps in Windows 11
To make your batch file into an app, first, you need to download and install one of these tools. After it’s installed, open the tool and find your batch file. Look for the “Invisible application” option or something similar, depending on the tool you’re using. The tool will then make your batch file into an app that you can run on any Windows computer without opening a command prompt window.
Just a heads up, some antivirus programs might think apps made from batch files are suspicious. If this happens, you might need to tell your antivirus that the app is safe.
Option 4: Run .BAT files in minimized mode
If you like seeing your batch file’s output but don’t want the CMD window to be big and in the way, you can add some lines to your batch file to make it start small. Use the start
command to begin a new process in a new window or console. The /min
option makes this new process start small. Put this command at the start of your batch file to run the rest of the script in a small window.
Here’s how your batch file could look:
@echo off start /min "yourbatchfile.bat" echo This will run in a small window. pause
In this setup, the @echo off
command stops the display of command prompt commands. The start /min cmd.exe
command opens a new command prompt window that’s small. The echo
command then shows a message in the small window, and the pause
command waits for you to press a key before the window closes.
Option 5: Use a third-party tool
Many tools can run batch files without showing any window at all or just a tiny one. “Hidden Start” by NTWind Software is one such tool. It’s a command-line tool that can run apps or batch files without showing a window. It has a few ways to run things, like totally hidden, small window, or as usual.
To use Hidden Start, download and install it from the NTWind Software website. Open a command prompt and go to where Hidden Start is installed. To run your batch file without showing a window, type this command:
hstart /NOCONSOLE "C:\Path\To\Your\BatchFile.bat"
This command makes Hidden Start run the batch file without showing a window. The file path should be where your batch file is.
To run your batch file in a small window, type this:
hstart /NOCONSOLE /MINIMIZED "C:\Path\To\Your\BatchFile.bat"
This command does the same thing but in a small window. All the other options are the same as before.
Just one more thing
While these methods are great for keeping the CMD window of a batch file out of sight, it’s super important to be careful with the scripts you’re running silently. Since there’s no visible window, it might be harder to spot if something goes wrong or if a script is doing something it shouldn’t.
Always double-check the scripts before setting them to run in the background or silently, especially if you downloaded them from the internet. Always safety first.
- September 11, 2022
- JavaScript
- How to call CMD without opening a window
- How to run a batch file without launching a «command window»? [duplicate]
- How to Run Console Programs Without a Console Window
- 3 Ways To Prevent Command Prompt From Closing After Running Commands
How to call CMD without opening a window
12. You can use the /C /Q switch. cmd.exe /c /q dir/b. this will run the
dir/b command and exit no window will be shown since we are settng the ECHO
off with the /q, but if you want to see the output before it closes then don’t
use the /q switch as. cmd.exe /c dir/b.
start \B example.exe arg1 arg2 arg3
start /min cmd
@echo off
cls && start /b cmd
cmd.exe /c /q dir/b
cmd.exe /c dir/b
cmd /c dir/b/s
cmd /c /q dir/b/s
cmd /c dir/b|clip
Starts a new instance of the Windows command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K (see below)
/Q Turns echo off
/D Disable execution of AutoRun commands from registry (see below)
/A Causes the output of internal commands to a pipe or file to be ANSI
/U Causes the output of internal commands to a pipe or file to be
Unicode
/T:fg Sets the foreground/background colors (see COLOR /? for more info)
/E:ON Enable command extensions (see below)
/E:OFF Disable command extensions (see below)
/F:ON Enable file and directory name completion characters (see below)
/F:OFF Disable file and directory name completion characters (see below)
/V:ON Enable delayed environment variable expansion using ! as the
delimiter. For example, /V:ON would allow !var! to expand the
variable var at execution time. The var syntax expands variables
at input time, which is quite a different thing when inside of a FOR
loop.
/V:OFF Disable delayed environment expansion.
Note that multiple commands separated by the command separator '&&'
are accepted for string if surrounded by quotes. Also, for compatibility
reasons, /X is the same as /E:ON, /Y is the same as /E:OFF and /R is the
same as /C. Any other switches are ignored.
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:
1. If all of the following conditions are met, then quote characters
on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters,
where special is one of: &<>()@^|
- there are one or more whitespace characters between the
two quote characters
- the string between the two quote characters is the name
of an executable file.
2. Otherwise, old behavior is to see if the first character is
a quote character and if so, strip the leading character and
remove the last quote character on the command line, preserving
any text after the last quote character.
If /D was NOT specified on the command line, then when CMD.EXE starts, it
looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if
either or both are present, they are executed first.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
Command Extensions are enabled by default. You may also disable
extensions for a particular invocation by using the /E:OFF switch. You
can enable or disable extensions for all invocations of CMD.EXE on a
machine and/or user logon session by setting either or both of the
following REG_DWORD values in the registry using REGEDIT.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions
to either 0x1 or 0x0. The user specific setting takes precedence over
the machine setting. The command line switches take precedence over the
registry settings.
In a batch file, the SETLOCAL ENABLEEXTENSIONS or DISABLEEXTENSIONS arguments
takes precedence over the /E:ON or /E:OFF switch. See SETLOCAL /? for details.
The command extensions involve changes and/or additions to the following
commands:
DEL or ERASE
COLOR
CD or CHDIR
MD or MKDIR
PROMPT
PUSHD
POPD
SET
SETLOCAL
ENDLOCAL
IF
FOR
CALL
SHIFT
GOTO
START (also includes changes to external command invocation)
ASSOC
FTYPE
To get specific details, type commandname /? to view the specifics.
Delayed environment variable expansion is NOT enabled by default. You
can enable or disable delayed environment variable expansion for a
particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You
can enable or disable delayed expansion for all invocations of CMD.EXE on a
machine and/or user logon session by setting either or both of the
following REG_DWORD values in the registry using REGEDIT.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
to either 0x1 or 0x0. The user specific setting takes precedence over
the machine setting. The command line switches take precedence over the
registry settings.
In a batch file the SETLOCAL ENABLEDELAYEDEXPANSION or DISABLEDELAYEDEXPANSION
arguments takes precedence over the /V:ON or /V:OFF switch. See SETLOCAL /?
for details.
If delayed environment variable expansion is enabled, then the exclamation
character can be used to substitute the value of an environment variable
at execution time.
You can enable or disable file name completion for a particular
invocation of CMD.EXE with the /F:ON or /F:OFF switch. You can enable
or disable completion for all invocations of CMD.EXE on a machine and/or
user logon session by setting either or both of the following REG_DWORD
values in the registry using REGEDIT.EXE:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar
and/or
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar
with the hex value of a control character to use for a particular
function (e.g. 0x4 is Ctrl-D and 0x6 is Ctrl-F). The user specific
settings take precedence over the machine settings. The command line
switches take precedence over the registry settings.
If completion is enabled with the /F:ON switch, the two control
characters used are Ctrl-D for directory name completion and Ctrl-F for
file name completion. To disable a particular completion character in
the registry, use the value for space (0x20) as it is not a valid
control character.
Completion is invoked when you type either of the two control
characters. The completion function takes the path string to the left
of the cursor appends a wild card character to it if none is already
present and builds up a list of paths that match. It then displays the
first matching path. If no paths match, it just beeps and leaves the
display alone. Thereafter, repeated pressing of the same control
character will cycle through the list of matching paths. Pressing the
Shift key with the control character will move through the list
backwards. If you edit the line in any way and press the control
character again, the saved list of matching paths is discarded and a new
one generated. The same occurs if you switch between file and directory
name completion. The only difference between the two control characters
is the file completion character matches both file and directory names,
while the directory completion character only matches directory names.
If file completion is used on any of the built in directory commands
(CD, MD or RD) then directory completion is assumed.
The completion code deals correctly with file names that contain spaces
or other special characters by placing quotes around the matching path.
Also, if you back up, then invoke completion from within a line, the
text to the right of the cursor at the point completion was invoked is
discarded.
The special characters that require quotes are:
<space>
&()[]{}^=;!'+,`~
start /b cmd /c "example.exe arg1 arg2 arg3"
'/q' is not recognized as an internal or external command,
operable program or batch file.
Set objShell = WScript.CreateObject("WScript.Shell")
isHidden = 0 'change 0 to 1 to show the CMD prompt
objShell.Run "%comspec% /c myfile.bat", isHidden
example.exe arg1 arg2 arg3
How to run a batch file without launching a «command window»? [duplicate]
You can also just make a shortcut to the .bat or .cmd file, then right-click
on the shortcut, Properties, Shortcut tab, Run: Minimized. Then in scheduled
tasks, …
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c testing.bat"
oShell.Run strArgs, 0, false
CreateObject("Wscript.Shell").Run "your_batch_file.bat", 0, True
If WScript.Arguments.Count >= 1 Then
ReDim arr(WScript.Arguments.Count-1)
For i = 0 To WScript.Arguments.Count-1
Arg = WScript.Arguments(i)
If InStr(Arg, " ") > 0 Then Arg = """" & Arg & """"
arr(i) = Arg
Next
RunCmd = Join(arr)
CreateObject("Wscript.Shell").Run RunCmd, 0, True
End If
NoShell.vbs c:\foo\my_batch_file.bat
@echo off
start /B go.bat
Run("C:\test\batchfile.bat", "", @SW_HIDE)
$x=0
Do
Run("C:\test\batchfile.bat", "", @SW_HIDE)
Sleep(5000)
Until $x = 1
#NoTrayIcon ; To prevent momentary icon pop-up
run whatever.bat arg1 arg2,,hide
How to Run Console Programs Without a Console Window
Solution 2: For Script Writers. Use the Run method as illustrated in the
following code snippet to execute the command: Set Shell = CreateObject
(«WScript.Shell») Shell.Run «»»Path to command or batch file»»», 0, False. Of
the three arguments to Run, the first is the full path to the executable or
batch file, the second sets the windows style
Set Shell = CreateObject("WScript.Shell")
Shell.Run """Path to command or batch file""", 0, False
3 Ways To Prevent Command Prompt From Closing After Running Commands
(Batch File Pause)
Then paste the following command at the end of your batch file. cmd /k. Next,
save the file by pressing “Ctrl+S” and close the notepad. Double click your
.bat file. You will see that CMD will remain open as long as you want …
cmd /k
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\powershell.exe\shell\open\command]
@=”\ ”C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\” –noExit \ “& \\\ “%1\\\ ”\””
[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command]
@=”\ “C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\ “ –NoExit \ “-Command\” \”if ( ( Get-ExecutionPolicy ) –ne ‘AllSigned’) { Set-ExecutionPolicy –Scope Process Bypass }; & \\\ ”%1” \\\ “\””