NirCmd is a powerful command-line utility for Windows that allows users to perform a wide range of system tasks quickly and efficiently without the need for complex scripting or additional software. With just a single command, users can control system functions, manage files, adjust audio settings, launch applications, and more. Whether you’re an IT professional, power user, or automation enthusiast, NirCmd offers a lightweight, flexible solution for streamlining repetitive tasks. This guide explores the many commands NirCmd can execute, providing practical examples and use cases to help you unlock its full potential and enhance your workflow with precision and ease.
System Control Commands
NirCmd enables you to execute essential system control functions directly from the command line. These commands are handy for scripting daily operations, automating shutdown procedures, or creating desktop shortcuts for quick access. Below is a breakdown of the most commonly used system control commands available in NirCmd.
Shut Down, Restart, and Log Off
Managing system power operations becomes effortless with NirCmd. Instead of navigating through Windows menus, you can perform actions instantly via the following commands:
Shut Down the Computer:
nircmd.exe exitwin shutdown
This command initiates a clean shutdown of your system. It is beneficial for automating shutdowns after backups, updates, or at the end of the workday.
Restart the Computer:
nircmd.exe exitwin reboot
Reboot your machine without any prompts. Ideal for remote management or batch updates that require a restart.
Log Off the Current User:
nircmd.exe exitwin logoff
Logs off the active user session. It can be used in shared environments to enforce session limits or prepare a workstation for the following user.
These commands can be scheduled via Task Scheduler or triggered from a desktop shortcut, giving users greater control over system behavior.
Lock the Workstation
Command:
nircmd.exe lockws
This command immediately locks the workstation, just like pressing Windows + L. It’s beneficial in corporate or multi-user environments where workstation security is a concern. You can add this command to a desktop shortcut, assign it to a hotkey, or integrate it into a script for quick session locking when idle or leaving your desk.
Turn Off the Monitor
Command:
nircmd.exe monitor off
Use this command to power down your monitor instantly. This doesn’t put the system to sleep it simply turns off the display output. It’s helpful in energy-saving scripts, during long-running processes that don’t require visual monitoring, or when leaving your workstation temporarily. The screen will automatically turn back on when mouse or keyboard activity is performed.
Practical Use Cases
- Scheduled System Shutdown: Automate system power-down every evening using Task Scheduler and the exit in shutdown command.
- Quick Lock Shortcut: Create a desktop shortcut with nircmd.exe locks to instantly secure your workstation with one click.
- Energy Conservation: Use the monitor off in an idle-time script to turn off the screen when not in use.
Audio Commands with NirCmd
NirCmd offers precise control over your system’s audio settings through simple command-line instructions. These commands are handy for automation scripts, remote system management, or quick sound adjustments without navigating through system menus.
Adjusting System Volume
To set the system volume, use the following command:
nircmd.exe setsysvolume [value]
The [value] should be a number between 0 (mute) and 65535 (maximum volume). For example, volume 32767 sets the volume to approximately 50%.
Muting and Unmuting Audio
To mute or unmute the system audio, use:
Mute Audio:
nircmd.exe mutesysvolume 1
Unmute Audio:
nircmd.exe mutesysvolume 0
These commands are ideal for incorporating into scripts for presentations, meetings, or scheduled events where silent mode is required.
File and Folder Operations with NirCmd
NirCmd provides a convenient way to perform essential file and folder management tasks directly from the command line, making it especially valuable for automation, scripting, and remote administration. Whether you need to copy files between directories, move data as part of a scheduled backup, or delete outdated files during cleanup routines, NirCmd streamlines these actions with simple syntax.
To copy a file, use:
nircmd.exe copy "source" "destination"
This command duplicates the file from the original location to the target folder, preserving the source file.
To move a file, use:
nircmd.exe move "source" "destination"
This transfers the file to a new location and removes it from the original path ideal for organizing files or archiving data.
- For deleting files, the following command removes a specified file immediately:
nircmd.exe deletefile "filepath"
This operation is silent and final, so caution is advised, mainly when used in scripts without user prompts.
Additionally, NirCmd makes it easy to create shortcuts to applications, files, or folders, which is helpful for customizing desktop environments or preparing user-friendly access points:
nircmd.exe shortcut "target" "folder" "shortcut name"
This command places a shortcut with the specified name in the target folder, linking directly to the original file or application.
These file and folder operations are fundamental for system administrators and advanced users looking to build efficient workflows, automate repetitive tasks, or maintain cleaner, more organized systems.
Process and Application Control
NirCmd allows you to launch or close applications quickly via the command line. To start a program, use:
nircmd.exe exec show "app_path"
This opens the specified application with its window visible, which is ideal for automation scripts or scheduled tasks.
To close a running program, use:
nircmd.exe killprocess "processname.exe"
This forcefully ends the specified process, which is helpful in shutting down apps automatically or handling unresponsive software. These simple yet powerful commands give you direct control over software behavior without manual interaction.
Window Management with NirCmd: Manipulating Active Windows
NirCmd offers precise control over open windows, allowing users to automate visibility, focus, and positioning without manual interaction. This is especially useful for productivity scripts or system automation tasks. Two commonly used commands for window management include:
Hide a Window by Title:
nircmd.exe win hide title "Window Title"
This command hides the specified window based on its title, removing it from view without closing the application.
Activate a Window by Class Name:
nircmd.exe win activate class "WindowClass"
This brings the specified window to the foreground using its class name, ensuring it becomes the active window for user interaction.
Clipboard and Text Manipulation with NirCmd
NirCmd provides convenient clipboard management commands that allow users to programmatically handle text data. These features are handy for automating workflows that involve copying or saving information.
Copy Text to the Clipboard
You can use NirCmd to copy any string directly to the Windows clipboard. This is helpful for automating form-filling, scripting repetitive tasks, or preparing data for pasting.
nircmd.exe clipboard set "Your text here"
Replace “Your text here” with any text you want to place on the clipboard.
Save Clipboard Content to a File
This command allows you to capture and save the current contents of the clipboard, whether text, images, or other data, into a file. It’s useful for logging, backups, or processing clipboard data.
nircmd.exe clipboard saveclp "output.txt"
This saves the clipboard content to a file named output.txt in the current directory.
Network and Internet Functions
NirCmd offers simple yet effective commands to manage network-related tasks directly from the command line. These functions are handy for IT administrators, network troubleshooters, or anyone looking to automate routine connectivity operations.
Open URLs in the Default Web Browser
NirCmd provides the exec show command to quickly launch a webpage using the system’s default browser. This is useful for scripting documentation links, login portals, or web-based tools.
Example:
nircmd.exe exec show "https://example.com"
Enable or Disable Network Adapters
NirCmd can turn network interfaces on or off using the setnicenabled command. This can be helpful for managing connectivity, running maintenance scripts, or troubleshooting network issues.
Disable a network adapter:
nircmd.exe setnicenabled "adapter name" 0
Enable a network adapter:
nircmd.exe setnicenabled "adapter name" 1
Note: Replace “adapter name” with the exact name of the network interface, which can be found in the Network Connections panel or via ipconfig /all.
Scheduled or Delayed Task Execution with NirCmd
Automate Time-Based Actions Using cmdwait for Precision Control
NirCmd enables users to schedule or delay the execution of specific commands using the cmdwait function. For example:
nircmd.exe cmdwait 5000 exec show notepad.exe
This command instructs NirCmd to wait 5,000 milliseconds (5 seconds) before launching Notepad. It’s instrumental in automation scripts where precise timing is critical such as giving a system time to close a process before starting another or staging commands in a logical sequence without external scheduling tools.
Advanced Scripting and Multi-Command Execution
NirCmd offers advanced scripting capabilities through multi-command execution, allowing users to chain several tasks into a single operation. This feature is ideal for automating complex workflows that require the execution of multiple commands in sequence. You can leverage multircmd or create a batch file to combine several NirCmd commands, enhancing efficiency and reducing manual intervention.
Example: Chaining Actions
A practical example would be to combine tasks like muting the system, waiting for a specified delay, and then shutting down the computer. The command sequence could look like this:
nircmd.exe mutesysvolume 1
nircmd.exe cmdwait 5000
nircmd.exe exitwin poweroff
This script mutes the volume, waits 5 seconds, and then shuts down the system allowing you to execute a series of commands in one seamless operation. This flexibility makes NirCmd an invaluable tool for system administrators, developers, and users seeking to automate their routine tasks.
Conclusion
Conclusion, NirCmd offers an extensive array of commands that enable users to efficiently manage system functions, automate tasks, and control applications with ease. From adjusting system volume to shutting down or restarting computers, controlling windows, and manipulating files, the tool simplifies complex operations. Its flexibility, combined with the ability to execute multiple commands and automate tasks, makes it an invaluable resource for both everyday users and advanced professionals. By exploring NirCmd’s wide range of commands, users can significantly enhance productivity and streamline workflows, all while maintaining complete control over their Windows environment.