NirCmd is one of those tools that belongs in every admin’s tool box. It was released in 2003 and the number of features has been growing ever since. It is hard to describe in a few words what you can actually do with this nifty tool because its functionality is so versatile. There is no special field of application; thus you could say it is a Swiss army knife for system administrators.

Latest posts by Michael Pietroforte (see all)

While the future of command line administration and scripting certainly belongs to PowerShell, I know that many admins still prefer simple batch scripts when it comes to scripting in a Windows environment. PowerShell is powerful, but it also requires a powerful memory if you only use it every now and then. What I like most about NirCmd is that its structure is so simple that one can easily memorize its commands.

Another advantage of simple batch scripts is that you can run them on every Windows box without installing .NET and PowerShell. Because NirCmd is only about 30KB, you can load it from a network share when you have to run a script on remote machines. In addition, it is possible to execute NirCmd commands on remote computers. You can explicitly add the computer names in your script or specify a text file with a list of the computers on which you want to run a specific NirCmd command.

To give you an idea about the multi-purpose character of NirCmd, I will list a few examples which I just copied from the NirSoft website. There you will find more examples and a description of how to use NirCmd.

Subscribe to 4sysops newsletter!

log off the current usernircmd.exe exitwin logoff
Ask if you want to reboot, and if you answer 'Yes', reboot the computer.nircmd.exe qboxcom "Do you want to reboot ?" "question" exitwin reboot
Turn off all computers specified in computers.txt!multiremote copy "c:\temp\computers.txt" exitwin poweroff force
Create a shortcut on your desktop that closes all your Internet Explorer windowsnircmd.exe cmdshortcut " "~$folder.desktop$ "Close All IE" win close class "IEFrame"
Create a shortcut to Windows calculator under Start Menu->Programs->Calculatorsnircmd.exe shortcut "f:\winnt\system32\calc.exe" "~$folder.programs$\Calculators" "Windows Calculator"
Kill (terminate) all instances of Internet Explorer processesnircmd.exe killprocess iexplore.exe
Set the display mode to 800x600x24bit colorsnircmd.exe setdisplay 800 600 24
Restart your Apache server (under Windows NT/2000/XP/2003)nircmd.exe service restart apache
Disable the screen savernircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 0
Copy the content of info1.txt (simple text file) to the clipboardnircmd.exe clipboard readfile "c:\My Files\info1.txt"
Install the specified .NET assembly in the global assembly cache (like gacutil)nircmd.exe gac install "C:\temp\MyAssembly\bin\MyAssembly.dll"


1 Comment
  1. Avatar

    If you need to create a shortcut to turn off the monitor : Nircmd Cmdwait 2000 Monitor Off

Leave a reply

Please enclose code in pre tags: <pre></pre>

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account