How to integrate NirCmd with Launchy to enhance productivity

by Scott Strain on October 20, 2008


NirCmd is a freeware utility that allows you to perform tasks from the command line, .bat files, desktop shortcuts and even Launchy. There’s a large list of commands on the NirCmd website. I’ve picked out a few that I’ve found useful, but you may find another great use for NirCmd after reading through the examples. This was written and tested in WindowsXP but it should also work in other versions of Windows.

To get started download NirCmd, the link is all the way at the bottom of the page. Next unzip the contents to a folder; I would suggest something simple such as C:\NirCmd\ if you use something else, substitute that wherever you see C:\NirCmd\

Note: NirCmd may display as a virus, spyware, or potentially unwanted program on some anti-virus and anti-spyware programs (Sophos is one) this is because certain viruses and spyware include and use NirCmd to perform actions on the users PC. However it is also used by many good programs as well, such as UBCD (which I may cover later), and by itself it poses no risk.

The simplest way to use NirCmd is in the command line, however this article will concentrate on writing commands out in a file and using desktop shortcuts and Launchy to run them. For a simple test, open up Notepad or your text-editor of choice and type in (or copy and paste):

C:\nircmd\nircmd.exe monitor off

Save the file in your C:\NirCmd\ folder as MonitorOff.bat the exact name does not matter, but it should describe what it does.

click to enlarge

Now you should have MonitorOff.bat sitting in the C:\NirCmd\ folder, double-click on it to put your monitor into power save mode (you can move the mouse or hit a key to turn it back on). You can then place a shortcut to MonitorOff.bat on your desktop, to do so Right-Click on MonitorOff.bat and select Send To and click Desktop (Create Shortcut). Another method I like to use is to simply select MonitorOff.bat with a single-click then hold down Alt and drag the file onto the desktop.

click to enlarge

If you look carefully in the above screenshot, you’ll notice another .bat file titled wait2 screenshot.bat this one is a set of two commands to wait two seconds and then take a screenshot which is saved as shot.png in C:\Nircmd this comes in handy to capture a screenshot when you can’t just hit Ctrl + Print Screen which I what I normally use for screenshots. Here is what the file contains:

C:\nircmd\nircmd.exe cmdwait 2000 savescreenshot “C:\Nircmd\shot.png”

Next up is a useful desktop shortcut to mute and un-mute the sound. In a new file enter:

C:\nircmd\nircmd.exe cmdshortcut “~$folder.desktop$” “Mute Unmute” mutesysvolume 2

Save the file in C:\NirCmd as Mute Unmute.bat you can also call change the “Mute Unmute” above in quotes to something else (the example on the website has “Switch Volume”), this will change the name of the desktop shortcut, you can also change any shortcut name later by right-clicking on it and selecting Rename. Now double-click on Mute Unmute.bat to create a new shortcut on your desktop that should mute the sound the first time it is double-clicked and un-mute it the next. If the default icon for this is too boring for you, right-click the Mute Unmute shortcut on your desktop and select Properties, select the Shortcut tab on top and click the Change Icon button. I personally like the speaker and music note icon as seen in the screenshot below.

click to enlarge

The question that originally led me to NirCmd was someone wanting a quick way to switch resolutions, as she wanted a lower resolution for older programs. For this example I will use 800×600 with 32 bit colors as the lower resolution and 1280×1024 with 32 bit colors as the higher resolution, although you can substitute other resolutions such as 1024×768 or widescreen resolutions such as 1440×900 and 1680×1050. The last number, color depth should be 32 unless you are running very old programs and want 16 bit colors. First, for the lower resolution file enter:

C:\nircmd\nircmd.exe cmdshortcut “~$folder.desktop$” “800×600″ setdisplay 800 600 32

and save it in C:\NirCmd as 800×600 Resolution.bat

click to enlarge

Moving on to the larger resolution, make a new file with:

C:\nircmd\nircmd.exe cmdshortcut “~$folder.desktop$” “1280×1024″ setdisplay 1280 1024 32

and save it in C:\NirCmd as 1280×1024 Resolution.bat

Now you can double-click each of these to make desktop shortcuts called 800×600 and 1280×1024, double-click on the desktop shortcuts to quickly resize the desktop. As in the Mute Unmute example, you can change the icons to whatever you feel like, here are two I picked out of the default set, I’ll have to remember to do a post on custom icons in the future.

Before moving into some more advanced command sets, I’ll explain how this can work with Launchy. Launchy should already scan the desktop for shortcuts and therefore find the examples that created desktop shortcuts. However, you may not want to have all commands as desktop shortcuts, or you may want to type up commands on the fly. To do either of these, the C:\NirCmd folder should be added to Launchy’s catalog. Bring up Launchy, Right-Click on it and select Options. Here click on the Catalog tab and hit the + (plus) button under Directories to add C:\Nircmd while it is selected type *.bat in the text-entry box under file types and hit the + button right underneath it. Do the same thing for *.exe, then make sure the box next to Executables is checked.

click to enlarge

Now click Rescan Catalog and Launchy should add all of your .bat files in the folder as well as nircmd.exe. To try this, bring up Launchy and type:


It should find the MonitorOff.bat before you finish typing, hit Enter to run it and it should turn off your monitor. All of the other .bat files created in C:\Nircmd should also be accessible by typing their filename in Launchy.

You can also enter an NirCmd command directly from Launchy, in the Launchy box type:


Next hit the Tab key and you should get nircmd -> in the launchy window. You can then type any Nircmd command after the ->

nircmd -> screensaver

will turn on the screensaver.

There are a lot of commands and examples to try out, especially since you can have multiple commands in a single .bat file. Next up is a quick set of commands to tidy up Windows and logoff (good for a computer that has multiple users):

C:\nircmd\nircmd.exe emptybin
C:\nircmd\nircmd.exe clipboard clear
C:\nircmd\nircmd.exe exitwin logoff

Save this as Logoff.bat in C:\NirCmd\ and when you are ready, running it will empty all of the recycling bins, clear the computer and log off the current user, be sure to only test this once you want to logoff as it will close all of your windows including unsaved documents.

Note: Depending on your Launchy settings you may have to Rescan Catalog after making new .bat files or desktop shortcuts. This option is on the General tab on the bottom as Minutes between catalog updates. If you have it set to 0 which is for manual updates only, then you will have to rescan the catalog whenever you want new commands and shortcuts added to Launchy.

There are many more commands to cover, including ones that manipulate files, enter text, or even move and click the mouse. Please feel free to leave a comment requesting additional help or examples.

  • Peter Gadd

    Haven’t had a good look at this yet, but I think it would be more useful with AutoHotKey than Launchy.

  • Enrique

    Great tuto man!!

  • colin

    hey great even works with my launch app called key launch but i can only get monitor off and empty recycl;e bin to work any reasons why i cant get the resolution one to work and can you put more on ;)

  • Ian

    Good tutorial, but is there any way to Switch User? Launchy itself will only allow you to Log Off so hoping NirCmd can add this.

  • Scott Strain

    I’m not sure off-hand why the monitor script is not working, I would check which resolutions you can use in your monitor’s display settings (right-click on the desktop and select properties and select the settings tab). Then try to set it to one of those resolutions with the command C:\NirCmd\nircmd.exe setdisplay 1024 768 32 or whatever resolution you need.

    I didn’t see any commands to switch user in the NirCmd documentation, however it is an active project where they will add new commands with each new version, so I would contact the dev team about getting it added for the next version.

  • Keba

    I just configured launchy to use the killprocess command, on a window I specify in launchy.
    I used the ‘runner’ plugin for this.
    I entered:

    ” killprocess $$.exe”

    By using this, i can pretty much do anything, istead of having to write a new batch file for every variable i need changed.

    (oh, and btw, the reason why I put nircmd in system32, is because I can run nircmd command easier from ‘run’, without having to type where it is stored).

  • dangage

    Esta bueno el programa pero le faltan mas comandos que los que muestra el archivo de ayuda tengo un comando que es muy util es para borrar los documentos recientes ( Recent )

    nircmd execmd del “~$folder.recent$\*.lnk*”

    copien y peguen y lo guardan como limpiar.bat y listo yo lo probe y funciona. suerte!!!