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.
- Poll: How reliable are ChatGPT and Bing Chat? - Tue, May 23 2023
- Pip install Boto3 - Thu, Mar 24 2022
- Install Boto3 (AWS SDK for Python) in Visual Studio Code (VS Code) on Windows - Wed, Feb 23 2022
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 user||nircmd.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 windows||nircmd.exe cmdshortcut " "~$folder.desktop$ "Close All IE" win close class "IEFrame"|
|Create a shortcut to Windows calculator under Start Menu->Programs->Calculators||nircmd.exe shortcut "f:\winnt\system32\calc.exe" "~$folder.programs$\Calculators" "Windows Calculator"|
|Kill (terminate) all instances of Internet Explorer processes||nircmd.exe killprocess iexplore.exe|
|Set the display mode to 800x600x24bit colors||nircmd.exe setdisplay 800 600 24|
|Restart your Apache server (under Windows NT/2000/XP/2003)||nircmd.exe service restart apache|
|Disable the screen saver||nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 0|
|Copy the content of info1.txt (simple text file) to the clipboard||nircmd.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"|
Want to write for 4sysops? We are looking for new authors.
If you need to create a shortcut to turn off the monitor : Nircmd Cmdwait 2000 Monitor Off