Running Windows Batch File
Run the batch file from a static command prompt so the window does not close. In the folder where the.bat files are located, hold down the 'shift' key and right click in the white space. Select 'Open Command Window Here'. You will now see a new command prompt. Type in the name of the batch file. Start “” c: windows otepad.exe file.txt. In double quotes, after start, the specification must specify the name of the batch file displayed in the command line header. This is an optional parameter, but in the absence of these quotes, executing bat files containing quotes in paths and parameters can go in unexpected ways. Trouble running.bat files Hi, I'm trying to run.bat files on Windows 10, but it tells me that 'This app can't run on your PC'. It doesn't matter what I use it for,.bat files just won't run anyway.
- Running Windows Batch File In Background
- Running Windows Batch File From Jenkins
- Running Windows Batch File Examples
- Run Windows Batch File From Cmd
Most ordinary Windows users never use the Command Prompt and have no idea what sort of things you can do from the command line. More experienced users will know that running command line commands can be very useful for a range of tasks and grouping everything into a single batch file to process it all together can be very powerful.
One inconvenience with running batch files is that they always open a console window which shows the output of the commands being executed. This can be important if you want to interact or see what is happening while the batch file is running but a bit annoying if you want to run the batch script quietly in the background or while starting windows.
For short batch files, the console window may appear and disappear in a flash or stay open for longer if more commands are being executed. There is no standard built in way to completely hide the console window from showing so if you want to do that another solution is required. Here we show you some different ways to make your batch script run silently without a console window showing.
Note: When using a method to hide the console window make sure the batch script contains no commands that are likely to stop the script before it exits, such as pause or requiring user input like a Yes/No response. For example, if a script has been converted into an executable and requires interaction, you won’t be able to do anything and the process will stay in Task Manager until it’s manually killed.
Run a Silent Batch Script Using a Third Party Utility
A simple and common solution for running a batch file silently is launching it via a third party utility that suppresses the console window.
Hidden Start (HStart)
Hidden Start is a portable and quite powerful tool that can launch executables and scripts with several useful options. We are using version 4.2 from 2013 because it’s portable and not as restricted as newer versions. Since version 4.3, Hidden Start is no longer portable and also pops up a nag every time you try to run a hidden console, which makes it useless for this purpose.
Unzip and run the program with HStartUI.exe, the process consists of three steps. Manually add or drop your batch file onto the window, make sure “Hide console window” is checked and optionally check “Run with highest privileges” if your script requires it. Other setup options like priority or starting directory are not essential unless you know the script requires them.
Step 3 shows the output command that has to be manually run. You can use the buttons at the bottom to copy the command, automatically create a shortcut or add an autostart entry into the registry. Note the bypass UAC prompt option is not available in the free version (we show you how to do that for free later).
Download Hidden Start
SilentCMD
This is a small 14KB tool that is not blessed with tons of features but does the simple task which we are looking for. If you are on Windows 10, .NET Framework 3.5 will be offered for install when running the tool if it isn’t already on your system. The basic syntax to use in shortcuts or similar is quite simple.
SilentCMD [path to .bat file] [batch arguments] [options]
There are two additional options in SilentCMD. One is to enable logging with “/log:[path to .txt]” and the other is to start the script after a delay using “/DELAY:[xx seconds]”. Append the option to the end of the command. As long as you don’t need extra functions like elevation or a different starting directory, SilentCMD works nicely and might be all that you need.
Download SilentCMD
NirCMD
Nirsoft’s NirCMD is a small multi function tool that can quietly perform dozens of tasks without popping up any console window. These include ejecting ROM drives, changing audio volumes, enabling screensavers, controlling processes/services and much more. The following command can be used at boot or in a shortcut to run a batch file silently:
nircmd exec hide [path to .bat file]
The exec and hide commands are used to execute the script and hide any console windows from opening.
Include elevatecmd to request administrator privileges for the batch file although it’s only needed if you know commands in your script require elevation.
nircmd elevatecmd exec hide [path to .bat file]
A desktop shortcut can be created manually or you can tell NirCMD to create a shortcut from the command line with the included commands so the silent script is ready to run.
nircmd cmdshortcut “~$folder.desktop$” “SilentBatch” exec hide C:UsersRaymondccMyBatchFile.bat
The above will create a desktop shortcut called SilentBatch which will silently execute the MyBatchFile.bat script. Note that you may have to change the “Start in” location in the shortcut as output from the script that doesn’t supply a path will default to C:Windows.
On double clicking the NirCMD executable it will offer the option to copy itself to the Windows directory so you only have to use nircmd.exe and not supply a full path every time. It’s advisable to do that if you plan to make use of NirCMD on your computer (make sure to right click and run nircmd.exe as administrator).
For full information about the wealth of commands available, have a read of the full NirCMD Help file.
Download NirCMD
Raymond.cc Silent Batch Launcher
We also have a little tool that can launch a batch file silently. It’s created in Autoit and is essentially a slightly advanced version of the “Create Your Own Executable File” method on page two. Silent Batch Launcher is designed to be simple to use and provide a slightly different option to the other tools here.
Run the executable and you will be asked to browse for a batch file. An INI file containing the path to the script will then be created next to the executable. Every time you run Silent Batch Launcher from then on it will execute the same batch file as long as the INI file is present.
To run a different script, delete the INI file or hold Shift while launching the tool and it will popup the file requester. The INI file name will match the EXE file name so you can have differently named occurrences of the tool in the same folder. There are two files in the archive, use the “Admin” version if the script requires elevation. Any useful feedback you have about the tool is welcome.
Download Silent Batch Launcher
Note: Because this tool was created with Autoit, it does create some false positives with online virus scanners like VirusTotal.
There are a few other tools that can hide the console window of a batch script that we haven’t mentioned here. They include Cmdow, Create Hidden Process, Hidecon, and Hideexec.
Hide the Batch Console With a Visual Basic Script
Hiding the batch script console window using Visual Basic is quite similar to using an external command and works in basically the same way. Launch the VB script and supply the batch file as an argument, then the code runs the script while not showing any output. It can be done with a single line of code.
CreateObject(“Wscript.Shell”).Run “””” & WScript.Arguments(0) & “”””, 0, False
Create an empty text file, copy and paste the above line then save it as a .vbs file. Alternatively, download launchquiet.vbs which is a ready made script. To add it to a shortcut or a startup location etc, use the commands in the following way. Don’t forget to use quotes if your paths or filenames contain spaces.
Wscript [path to .vbs file] [path to .bat file]
If you would like to supply an argument for the batch file, the piece of VB script has to be altered slightly by changing the two sets of four double quotes to two sets of two.
CreateObject(“Wscript.Shell”).Run “” & WScript.Arguments(0) & “”, 0, False
Then supply the arguments along with the batch script path inside quotes:
Wscript [path to .vbs file] “[path to .bat file] [argument]”
Again, for convenience, you can download a ready madelaunchquiet_args.vbs script file.
On the next page, we’ll look at how to convert a batch script into an executable file, how to create a batch executable without any additional software and how to run a script from a scheduled task.
12Next › View All You might also like:
7 Ways to Measure Time Taken to Complete a Batch File or Command Line Execution6 Ways To Batch Create Multiple Folders at Once5 Ways to Trigger UAC Elevation from Command Line7 Ways To Remove Duplicate Lines in Text Files2 Ways to Convert REG to EXE, BAT, VBS and AU3 to Bypass Registry Editing Restriction 12 Comments - Write a Comment
Here is another implementation: stackoverflow.com/a/56111754/70405
ReplyThank you for nice article, after a research found nircmd is the easiest and best utility
ReplyHi Jeremy,
Can I add the lines provided by you directly in my batch file after @echo off?
Thank you,
Kiran.
Another option: create a Windows shortcut and use this as the path:
cmd.exe /c echo CreateObject(“Wscript.Shell”).Run “notepad.exe”, 0, false > run_hidden.vbs & start /wait wscript run_hidden.vbs & del run_hidden.vbs
ReplyThank you This helped me a lot.
Reply“Run whether user is logged on or not will not work no matter what you do”
True!
You need to use that or it won’t hide the console window, if you use “run only when user is logged in”, a console window will appear, which is what we a trying to avoid.
ReplyThank you so much!!
ReplyYou missed a tool that has been around for 16 years.
joeware.net/freetools/tools/quiet/index.htm
The article is not about listing every single tool around that can hide a console window.
ReplyThanks a lot for “Run A Silent Batch Script Using A Scheduled Task”.
It saved me a 2 minutes popup every 10 minutes :)
Run whether user is logged on or not will not work no matter what you do
ReplyLeave a Reply
Windows 8 64-bit. The user I'm logged in as has admin rights. When I open a cmd windows the window title even says 'Administrator: cmd.exe'.
So, I set my .bat file association to have the .bat file opened in Notepad++, and now I can't set it back to run the bat file when I double click on it. I've tried several web pages which told me to edit the registry to no avail.
When I do try to merge a .reg file into my PC, I get an error 'You do not have permissions' or something. My user is not 'administrator' but my user 'chuck' does have admin rights. It always has.
I tried this method, the .reg file merged without error this time, but when I double click on a .bat file it still opens in Notepad++. I downloaded the file to change the .bat file assoc only. Do I have to restart the PC?
I also tried making the registry edits here: click here. It didn't work either.
The .bat file extension cannot be changed in the Associate File Extension with a Program in the Control panel. When I try to associate cmd.exe with a .bat file I get an error like 'You cannot associate that program with this file.'
I found this link but there is no .bat file entry under FileExts. Also on this link I have no no UserChoice key to delete for
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.batUserChoice
.Rebooted PC, I still have the same problem. I will make sure Notepad++ is not restoring associations with itself each time it runs. EDIT: As far as NPP preferences are concerned, it does not register .bat files.
Any more ideas? I have been dealing with this for 3 months off and on now.
Adobe Flash CS3 is design software developed and manufactured by Adobe systems to create interactive content for websites and games. It is available personal computers, mobile phones and other portable devices including tablets and laptops. In this software Adobe Flash CS3 Free Download we can create flash projects also Purpose of This software people can easy create animations For Movies, Drama, Games and other things other software is so difficuilt to Understand.and This software is much popular now a days.when you use this you will Not face any Difficuilty. Adobe Flash CS3 Professional is a powerful tool that allows you to create comprehensive interactive animations and vector graphics for use on Web pages. This application allows you to combine multiple items into one project: vector graphics, bitmap graphics, sound, etc. Flash cs3 software.
NOTE: Some fixes for this problem work on Windows 7 but DO NOT work on Windows 8.
UPDATE: Fixed it. I had to
- Make a shortcut to regedt32.exe on my desktop.
- Right click shortcut and do 'Run As Administrator', even though my user has admin rights.
- Search the whole registry for the string 'notepad' whereon I found the sneaky little thing here:
HKEY_CURRENT_USERSoftwareMicrosoftWindows**Roaming**OpenWithFileExts.bat
and deleted theUserChoice
item. - Reboot windows.
2 Answers
Running Windows Batch File In Background
I have the same problem on Windows 10. I solved it by following the steps below.
- run regedit with admin privilege. on Windows 10, open any Explorer window (i.e., file folder), press 'Alt-F S A' (without the quote nor the spaces), and PowerShell window will open. type 'regedit', then return. the regedit window will open.
- go to HKEY_CURRENT_USERSoftwareMicrosoft.
search for '.bat', specifying that whole field must be the same.on my computer it happens to be at:HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.bat
verify that there is a 'UserChoice', which specifies the editor or whatever you specified.
- remove 'UserChoice'.
- exit regedit.
Now double click on any .bat file and it should run.
I did not need to restart my PC, which runs Windows 10.
This assumes you are an administrator
You can set associations from the command line start->run->enter 'cmd' (no quotes) and press enter
Running Windows Batch File From Jenkins
Then type
Running Windows Batch File Examples
This will give you the filetype the OS thinks a .bat file is/does/whatever
This will give you the command which runs when you 'execute' the file - assuming that the first command returns '.bat=batfile' you need to set the association and you do so with this command
Run Windows Batch File From Cmd
protected by RamhoundMar 31 at 15:01
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?