Download NirCmd.zip, a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more...
Examples of what you can do with NirCmd
Open the door of J: CD-ROM drive | nircmd.exe cdrom open j: |
Close the door of Y: CD-ROM drive | nircmd.exe cdrom close y: |
Increase the system volume by 2000 units (out of 65535) | nircmd.exe changesysvolume 2000 |
Decrease the system volume by 5000 units (out of 65535) | nircmd.exe changesysvolume -5000 |
Set the volume to the highest value | nircmd.exe setsysvolume 65535 |
Mute the system volume | nircmd.exe mutesysvolume 1 |
Unmute the system volume | nircmd.exe mutesysvolume 0 |
Switch the system volume between the mute and normal state. | nircmd.exe mutesysvolume 2 |
Create a shortcut on your desktop that switch the system volume between the mute and normal state. | nircmd.exe cmdshortcut "~$folder.desktop$" "Switch Volume" mutesysvolume 2 |
Turn off the monitor | nircmd.exe monitor off |
Start the default screen saver | nircmd.exe screensaver |
Put your computer in 'standby' mode | nircmd.exe standby |
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 your computer | nircmd.exe exitwin poweroff |
Turn off all computers specified in computers.txt ! | multiremote copy "c:\temp\computers.txt" exitwin poweroff force |
Dial to "My Internet" connection | nircmd.exe rasdial "My Internet" |
Disconnect the "My Internet" connection | nircmd.exe rashangup "My Internet" |
Make your Internet Explorer windows 75% transparent ! (192 / 256) | nircmd.exe win trans ititle "internet explorer" 192 |
Minimize all your Internet Explorer windows | nircmd.exe win min class "IEFrame" |
Close all your Internet Explorer windows | nircmd.exe win close class "IEFrame" |
Close all your Explorer windows (My Computer, folders, and so on) | nircmd.exe win close class "CabinetWClass" |
Hide all your Internet Explorer windows | nircmd.exe win hide class "IEFrame" |
Show all your Internet Explorer windows (after you made them hidden with previous example) | nircmd.exe win show class "IEFrame" |
Center all top-level windows | nircmd.exe win center alltop |
Remove the title bar of My Computer window. | nircmd.exe win -style title "my computer" 0x00C00000 |
Return the title bar of My Computer window that we removed in the previous example. | nircmd.exe win +style title "my computer" 0x00C00000 |
Set the My Computer window to right-to-left order (For hebrew and arabic languages) | nircmd win +exstyle title "my computer" 0x00400000 |
Set all child windows of My Computer window to right-to-left order (For hebrew and arabic languages) | nircmd win child title "my computer" +exstyle all 0x00400000 |
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 on your desktop that hides all your Internet Explorer windows | nircmd.exe cmdshortcut " "~$folder.desktop$ "Hide All IE" win hide class "IEFrame" |
Create a shortcut on your desktop that shows back all your Internet Explorer windows | nircmd.exe cmdshortcut " "~$folder.desktop$ "Show All IE" win show class "IEFrame" |
Set the Windows Calculator as top-most window (above all other windows) | nircmd.exe win settopmost title "Calculator" 1 |
Set the Windows Calculator back to regular window (non top-most window) | nircmd.exe win settopmost title "Calculator" 0 |
Create a shortcut to Windows calculator under Start Menu->Programs->Calculators | nircmd.exe shortcut "f:\winnt\system32\calc.exe" "~$folder.programs$\Calculators" "Windows Calculator" |
Hide the desktop window | nircmd.exe win hide class progman |
Show the desktop window (After hiding it in previous example) | nircmd.exe win show class progman |
Hide the start button on the system tray | nircmd.exe win child class "Shell_TrayWnd" hide class "button" |
Show the start button on the system tray | nircmd.exe win child class "Shell_TrayWnd" show class "button" |
Hide the clock on the system tray | nircmd.exe win child class "Shell_TrayWnd" hide class "TrayClockWClass" |
Show the clock on the system tray | nircmd.exe win child class "Shell_TrayWnd" show class "TrayClockWClass" |
Kill (terminate) all instance of Internet Explorer processes | nircmd.exe killprocess iexplore.exe |
Create a shortcut on your desktop that opens the door of K: CDROM drive when you run it. | nircmd.exe cmdshortcut "~$folder.desktop$" "Open CDROM" cdrom open k: |
Create a shortcut to NirSoft Web site on your desktop | nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.desktop$" "NirSoft" |
Add NirSoft Web site to your Favorities under Links folder. | nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.favorites$\Links" "NirSoft" |
Create a shortcut to NirSoft Web site on the desktop of all computers listed in computers.txt | nircmd.exe multiremote copy "c:\temp\computers.txt" urlshortcut "http://www.nirsoft.net" "~$folder.common_desktop$" "NirSoft" |
Set the display mode to 800x600x24bit colors | nircmd.exe setdisplay 800 600 24 |
Create a shortcut on the desktop that set the display mode to 800x600x24bit colors | nircmd.exe cmdshortcut "~$folder.desktop$" "800x600x24" setdisplay 800 600 24 |
Copy all shortcuts on your desktop to another folder (f:\temp\desktop). | nircmd.exe execmd copy "~$folder.desktop$\*.lnk" f:\temp\desktop |
Restart your Apache server (under Windows NT/2000/XP/2003) | nircmd.exe service restart apache |
Create a shortcut on your desktop that restarts the Apache server | nircmd.exe cmdshortcut "~$folder.desktop$" "Restart Apache" service restart apache |
Restart your IIS | nircmd.exe service restart w3svc |
Restart MySql | nircmd.exe service restart MySql |
Open the desired Registry key/value in RegEdit | nircmd.exe regedit "HKLM\Software\Microsoft\Windows\CurrentVersion" "CommonFilesDir" |
Open the Registry key that you copied to the clipboard in RegEdit. | nircmd regedit "~$clipboard$" |
Disable the screen saver | nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 0 |
Enable the screen saver | nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 1 |
Change the date/time of the specified filename (creation time and modified time) | nircmd.exe setfiletime "c:\temp\myfile.txt" "24-06-2003 17:57:11" "22-11-2005 10:21:56" |
Copy your desktop folder path to the clipboard | nircmd.exe clipboard set ~$folder.desktop$ |
Copy your start menu folder path to the clipboard | nircmd.exe clipboard set ~$folder.start_menu$ |
Copy the content of info1.txt (simple text file) to the clipboard | nircmd.exe clipboard readfile "c:\My Files\info1.txt" |
Add the text content of clipboard to info1.txt | nircmd.exe clipboard addfile "c:\My Files\info1.txt" |
Clear the clipboard | nircmd.exe clipboard clear |
Create all folders specified in "c:\temp\folders.txt". The folder path names are separated by CRLF characters. | nircmd.exe paramsfile "c:\temp\folders.txt" "" "" execmd md ~$fparam.1$ |
Install the specified .NET assembly in the global assembly cache (like gacutil) | nircmd.exe gac install "C:\temp\MyAssembly\bin\MyAssembly.dll" |
Empty the recycle bin in all drives. | nircmd.exe emptybin |
System Requirements
This utility can work in all 32-bit Windows operating systems: Windows 9x/ME, Windows NT, Windows 2000, and Windows XP. However, some of NirCmd commands works only on Windows NT/2000/XP.Versions History
Date | Version | Description |
---|---|---|
24/07/2006 | 1.85 |
|
15/07/2006 | 1.84 |
|
20/05/2006 | 1.83 |
|
18/02/2006 | 1.82 |
|
19/11/2005 | 1.81 |
|
24/09/2005 | 1.80 |
|
07/07/2005 | 1.70 |
|
10/06/2005 | 1.62 |
|
26/05/2005 | 1.61 |
|
07/05/2005 | 1.60 |
|
28/12/2004 | 1.56 |
|
07/12/2004 | 1.55 | Added RegEdit command. |
18/11/2004 | 1.54 |
|
03/11/2004 | 1.53 | Fixed 'monitor off' problem in XP SP2. |
09/10/2004 | 1.52 | rasapi32.dll is now loaded only when using the dial commands (rasdial, rasdialdlg, rashangup). In previous versions, NirCmd was statically linked to rasapi32.dll, and that caused problems in old NT systems. |
29/09/2004 | 1.51 |
Variable names are now enclosed with '$' char instead of '%' char.
I made this change because the '%' char causes problems when running NirCmd from cmd/bat file. using the '%' char for variable names is still supported for backward compatibility. |
22/09/2004 | 1.50 |
|
05/05/2004 | 1.40 |
|
01/03/2004 | 1.30 |
|
08/01/2004 | 1.20 |
|
19/11/2003 | 1.11 | New options in shortcut command |
10/10/2003 | 1.10 | New commands: killprocess, service, memdump, win, lockws. |
09/09/2003 | 1.00 | First release. |
License
This utility is released as freeware. You are allowed to freely distribute this utility via floppy disk, CD-ROM, Internet, or in any other way, as long as you don't charge anything for this. If you distribute this utility, you must include all files in the distribution package, without any modification !Using NirCmd utility
This utility is a standalone executable, and it doesn't require any installation process or additional DLLs. just copy the executable to any folder you want, and run it with the desired command-line option, according to your needs.It's recommended to copy the executable of NirCmd (nircmd.exe) to your windows directory, or to any other folder listed in your PATH environment variable, so you won't need to type the full path of nircmd in each time that you want to use it.
Starting from version 1.50, console version of NirCmd (nircmdc.exe) is also available. In the console version, all error messages goes to the console window, instead of using a message box.
General Syntax Of NirCmd
nircmd.exe \{showerror\} \[command\] \[command parameters\]The showerror parameter is optional. If you specify this parameter, an error message will be displayed on the screen if an error is occurred during the execution of the command. Otherwise, any error will be ignored. For example:
nircmd.exe showerror rasdial "dial1"
nircmd.exe rasdial "dial1"
In above 2 examples, NirCmd will try to dial with the "dial1" entry. If the dialing process is failed on the first example, an error message describing the problem will be displayed. If the dialing process is failed on the second example, error message won't be displayed.
Special String Sequences
Starting from version 1.20, NirCmd allows you to insert special characters into any parameter in NirCmd commands.The following table describes the special string Sequences that you can use:
Sequence | Description |
---|---|
~n | New line characters (CR-LF) |
~q | Double-quote character: " |
~t | Tab character |
~xnn |
Allows you to represent any character by providing its ascii code in 2-digit Hexadecimal number.
For Example: ~x41 ('A' character), ~x27 (single-quote character) |
~$variable$ | Represents a system variable. For more information about this option, read below |
~~ | Represents a single '~' character. |
Example:
infobox "This is the first line~n~qThis is a second line, in quotes~q" "Example"
The above example displays a message-box containing 2 lines.
System Variables
Starting from version 1.40, NirCmd provides special variables that represents folders and other variables on your system. Each variable starts with '~' character, followed by the variable name enclosed with '$' characters. For example: ~$folder.desktop$ represents your desktop folder.The following table specifies the variables that you can use:
Variable Name | Description |
---|---|
clipboard | Represents the text that you copied into the clipboard. |
param.paramname |
When you specify a param variable, an input window will appear on the screen,
and will ask you to type the text for this variable.
The text that you type will be inserted into the command line.
For example: in the following command, you will be asked to type 2 parameters (1 and 2), and the text that you type will appear in the message box. nircmd infobox ~$param.1$ ~$param.2$
|
fparam.number | Sepcifies a parameter loaded from a text file. For more information, see paramsfile command |
sys.varname |
You can use this option to represent any environment variable on your system.
For example: ~$sys.username$, ~$sys.windir$, ~$sys.computername$, ~$sys.logonserver$, ~$sys.temp$, and so on... |
nir.exefile | Represents the full-path exe file of the current running NirCmd (For example: c:\winnt\nircmd.exe) |
folder.nircmd | Represents the folder the NirCmd is running from. |
folder.desktop | Represents the user's desktop folder. |
folder.start_menu | Represents the user's start-menu folder. |
folder.programs | Represents the user's programs folder (under the start-menu folder). |
folder.startup | Represents the user's startup folder. |
folder.recent | Represents the user's recent folder. |
folder.favorites | Represents the user's favorites folder. |
folder.cookies | Represents the user's cookies folder. |
folder.appdata | Represents the user's Application Data folder. (For example: C:\Documents and Settings\Administrator\Application Data) |
folder.common_desktop | Represents the common desktop folder. |
folder.common_start_menu | Represents the common start menu folder. |
folder.common_programs | Represents the common programs folder. |
folder.common_startup | Represents the common startup folder. |
folder.common_favorites | Represents the common favorites folder. |
folder.windows | Represents the windows folder. (e.g.: C:\Windows) |
folder.system | Represents the system folder. (e.g.: C:\Windows\System32) |
Examples:
- Create a shortcut under the start menu-programs folder:
shortcut "c:\winnt\system32\calc.exe" "~$folder.programs$\My Programs" "Calculator" - Delete a shortcut in the user's desktop:
execmd del "~$folder.desktop$\calc.lnk" - Display the current logged-on user:
infobox "The current logged-on user is ~$sys.username$" "logged-on user"
Executing NirCmd commands on remote computers
Starting from version 1.40, you can execute all NirCmd commands in remote computers. However, you should be aware of the following restrictions and problems:- This option is only available for Windows NT, Windows 2000 and Windows XP. You cannot use it on Windows 9x machines.
- You must log on to the remote machine as administrator.
- The Schedule service in the remote machine must be started. (By default, the Schedule service is automatically started in all NT/2000/XP machines, so you don't have to worry too much about this)
- Due to some limitations of the Schedule service, you have to wait up to 60 seconds until the command is actually executed in the remote machine.
- The command in the remote machine is executed under 'SYSTEM' account, and thus some commands may not work in the same way as you execute them locally.
There are 2 commands for executing NirCmd in remote machines:
- remote - for executing command on a single remote computer.
- multiremote - for executing command on multiple remote computers.