Running a batch file without displaying a console window
May 17th, 2005
Problem:
I have a batch file that I want to run without it displaying the command console window.
For the sake of an example, let's say this file is on my desktop and is called helpfile.bat. The file contains a single line:
HH.EXE -mapid 2001 ms-its:D:\CVS_local_copy\myhelp\helpfile.chm
This batch file opens up a help file, displaying a particular help topic (referenced by a map ID). I want to be able to double-click the desktop icon and get the Help viewer, without the console window.
Solution:
To do this I use NirCmd.exe from NirSoft (www.nirsoft.net/utils/nircmd.html).
1. Download NirCmd.
It's a free download. The zip file contains the two .exe files and a very useful .chm help file.
2. Make a NirCmd directory and extract the zip contents to this directory.
3. Create a desktop shortcut with a target such as C:\path\to\nircmd\nircmd.exe exec hide "C:\path\to\youbatchfile.bat"
e.g.
C:\Program Files\NirCmd\NirCmd.exe exec hide "C:\Documents and Settings\Alistair\Desktop\helpfile.bat"
Double-click the shortcut and the command in the batch file is executed without the console window being displayed.
In my example, it's a bit dumb having both the batch file on the desktop, but you can put it wherever you like.
NirCmd allows you to create shortcuts to do all sorts of things, like changing the resolution of you monitor, turning off your PC, etc. – any command you can run from Start > Run.
Potentially similar posts
- Scan for available IP addresses – August 2011
- Rails Chronicles – Part 2 – July 2011
- My first (useful) Ruby program – June 2011
- Perl basics for beginners (on Windows) – August 2010
- Preventing BBC iPlayer running all the time – November 2008