NirCmd - Windows Command Line Tool

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Main Page

NirCmd v2.86
Blog
Copyright (c) 2003 - 2019 Nir Sofer
Search
FAQ
See Also
TOP 10
Pad Files SoundVolumeView - Display, change, mute, unmute the volume level of sound components on
Contact Windows 10/7/8/2008 from command line or GUI .
About... NK2Edit - Edit, merge and fix the AutoComplete files (.NK2) of Microsoft Outlook.
Donate
Description
All Utilities
Password Tools
NirCmd is a small command-line utility that allows you to do some useful tasks without displaying
System Tools any user interface. By running NirCmd with simple command-line option, you can write and delete
Browser Tools values and keys in the Registry, write values into INI file, dial to your internet account or connect to a
Programmer Tools 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
Network Tools
your CD-ROM drive, and more...
Outlook/Office
64-bit Download Examples of what you can do with NirCmd
Panel
Forensics
Open the door of J: nircmd.exe cdrom open j:
Pre-Release Tools CD-ROM drive
Articles
Close the door of Y: nircmd.exe cdrom close y:
CD-ROM drive
Speaks the text
currently in the
clipboard (For speak text ~$clipboard$
Windows
XP/Vista/7/8).
Speaks the text
stored inside
speak.txt into speak file "c:\temp\speak.txt" 0 100 "c:\temp\speak.wav" 48kHz16BitStereo
speak.wav filename
(For Windows
XP/Vista/7/8).

Increase the system


volume by 2000 nircmd.exe changesysvolume 2000
units (out of 65535)
Decrease the system
volume by 5000 nircmd.exe changesysvolume -5000
units (out of 65535)

Set the volume to nircmd.exe setsysvolume 65535


the highest value

Mute the system nircmd.exe mutesysvolume 1


volume

Unmute the system nircmd.exe mutesysvolume 0


volume

Switch the system


volume between the
nircmd.exe mutesysvolume 2
mute and normal
state.
Create a shortcut on nircmd.exe cmdshortcut "~$folder.desktop$" "Switch Volume"
your desktop that mutesysvolume 2
switch the system
volume between the
mute and normal
state.

Turn off the monitor nircmd.exe monitor off

Start the default


nircmd.exe screensaver
screen saver
Put your computer
nircmd.exe standby
in 'standby' mode
log off the current nircmd.exe exitwin logoff
user

Ask if you want to


reboot, and if you nircmd.exe qboxcom "Do you want to reboot ?" "question" exitwin reboot
answer 'Yes', reboot
the computer.
Turn off your
nircmd.exe exitwin poweroff
computer
Turn off all
computers specified multiremote copy "c:\temp\computers.txt" exitwin poweroff force
in computers.txt !

Dial to "My nircmd.exe rasdial "My Internet"


Internet" connection
Disconnect the "My
nircmd.exe rashangup "My Internet"
Internet" connection

Make your Internet


Explorer windows nircmd.exe win trans ititle "internet explorer" 192
75% transparent !
(192 / 256)

Minimize all your


Internet Explorer nircmd.exe win min class "IEFrame"
windows
Close all your
Internet Explorer nircmd.exe win close class "IEFrame"
windows
Close all your
Explorer windows
nircmd.exe win close class "CabinetWClass"
(My Computer,
folders, and so on)
Hide all your
Internet Explorer nircmd.exe win hide class "IEFrame"
windows

Show all your


Internet Explorer
windows (after you
nircmd.exe win show class "IEFrame"
made them hidden
with previous
example)
Center all top-level nircmd.exe win center alltop
windows

Remove the title bar nircmd.exe win -style title "my computer" 0x00C00000
of My Computer
window.
Return the title bar
of My Computer
window that we nircmd.exe win +style title "my computer" 0x00C00000
removed in the
previous example.
Set the My
Computer window
to right-to-left order nircmd win +exstyle title "my computer" 0x00400000
(For hebrew and
arabic languages)
Set all child
windows of My
Computer window nircmd win child title "my computer" +exstyle all 0x00400000
to right-to-left order
(For hebrew and
arabic languages)

Create a shortcut on
your desktop that
nircmd.exe cmdshortcut " "~$folder.desktop$ "Close All IE" win close class
closes all your "IEFrame"
Internet Explorer
windows
Create a shortcut on
your desktop that
nircmd.exe cmdshortcut " "~$folder.desktop$ "Hide All IE" win hide class
hides all your "IEFrame"
Internet Explorer
windows

Create a shortcut on
your desktop that
nircmd.exe cmdshortcut " "~$folder.desktop$ "Show All IE" win show class
shows back all your "IEFrame"
Internet Explorer
windows

Set the Windows


Calculator as top- nircmd.exe win settopmost title "Calculator" 1
most window (above
all other windows)

Set the Windows


Calculator back to nircmd.exe win settopmost title "Calculator" 0
regular window (non
top-most window)

Create a shortcut to
Windows calculator
nircmd.exe shortcut "f:\winnt\system32\calc.exe"
under Start Menu- "~$folder.programs$\Calculators" "Windows Calculator"
>Programs-
>Calculators

Hide the desktop nircmd.exe win hide class progman


window
Show the desktop
window (After nircmd.exe win show class progman
hiding it in previous
example)

Hide the start button nircmd.exe win child class "Shell_TrayWnd" hide class "button"
on the system tray

Show the start nircmd.exe win child class "Shell_TrayWnd" show class "button"
button on the system
tray
Hide the clock on nircmd.exe win child class "Shell_TrayWnd" hide class "TrayClockWClass"
the system tray
Show the clock on nircmd.exe win child class "Shell_TrayWnd" show class "TrayClockWClass"
the system tray
Kill (terminate) all
instance of Internet nircmd.exe killprocess iexplore.exe
Explorer processes
Create a shortcut on
your desktop that
opens the door of K: nircmd.exe cmdshortcut "~$folder.desktop$" "Open CDROM" cdrom open k:
CDROM drive when
you run it.
Create a shortcut to
NirSoft Web site on nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.desktop$" "NirSoft"
your desktop
Add NirSoft Web
site to your nircmd.exe urlshortcut "http://www.nirsoft.net" "~$folder.favorites$\Links"
Favorities under "NirSoft"
Links folder.

Create a shortcut to
NirSoft Web site on
nircmd.exe multiremote copy "c:\temp\computers.txt" urlshortcut
the desktop of all "http://www.nirsoft.net" "~$folder.common_desktop$" "NirSoft"
computers listed in
computers.txt

Set the display mode


to 800x600x24bit nircmd.exe setdisplay 800 600 24
colors

Create a shortcut on
the desktop that set
nircmd.exe cmdshortcut "~$folder.desktop$" "800x600x24" setdisplay 800
the display mode to 600 24
800x600x24bit
colors

Copy all shortcuts


on your desktop to
nircmd.exe execmd copy "~$folder.desktop$\*.lnk" f:\temp\desktop
another folder
(f:\temp\desktop).
Restart your Apache
server (under nircmd.exe service restart apache
Windows
NT/2000/XP/2003)

Create a shortcut on
your desktop that nircmd.exe cmdshortcut "~$folder.desktop$" "Restart Apache" service
restarts the Apache restart apache
server
Restart your IIS nircmd.exe service restart w3svc

Restart MySql nircmd.exe service restart MySql

Open the desired


nircmd.exe regedit "HKLM\Software\Microsoft\Windows\CurrentVersion"
Registry key/value "CommonFilesDir"
in RegEdit
Open the Registry
key that you copied nircmd regedit "~$clipboard$"
to the clipboard in
RegEdit.
Disable the screen nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 0
saver

Enable the screen nircmd.exe regsetval sz "HKCU\control panel\desktop" "ScreenSaveActive" 1


saver
Change the
date/time of the
nircmd.exe setfiletime "c:\temp\myfile.txt" "a24-06-2003 17:57:11" "a22-11-
specified filename 2005 10:21:56"
(creation time and
modified time)
Copy your desktop
folder path to the nircmd.exe clipboard set ~$folder.desktop$
clipboard

Copy your start


menu folder path to nircmd.exe clipboard set ~$folder.start_menu$
the clipboard

Copy the content of


info1.txt (simple text nircmd.exe clipboard readfile "c:\My Files\info1.txt"
file) to the clipboard

Add the text content


of clipboard to nircmd.exe clipboard addfile "c:\My Files\info1.txt"
info1.txt

Clear the clipboard nircmd.exe clipboard clear

Create all folders


specified in
"c:\temp\folders.txt". nircmd.exe paramsfile "c:\temp\folders.txt" "" "" execmd md ~$fparam.1$
The folder path
names are separated
by CRLF characters.

Install the specified


.NET assembly in nircmd.exe gac install "C:\temp\MyAssembly\bin\MyAssembly.dll"
the global assembly
cache (like gacutil)
Empty the recycle
nircmd.exe emptybin
bin in all drives.

Answer 'Yes' to a
standard Windows nircmd.exe dlg "" "" click yes
message-box.

Wait 2 seconds, and


then save the current nircmd.exe cmdwait 2000 savescreenshot "f:\temp\shot.png"
screen to shot.png
Save 10 screenshots
in a loop, and wait
60 seconds between
the screenshot save
nircmd.exe loop 10 60000 savescreenshot
calls. The filenames c:\temp\scr~$currdate.MM_dd_yyyy$-~$currtime.HH_mm_ss$.png
of the screenshot
will contain the time
and date of the
saved screenshot.
Wait until Firefox is
closed, and then say nircmd.exe waitprocess firefox.exe speak text "Firefox was closed"
"Firefox was closed"
Run RegEdit with nircmd.exe elevatecmd runassystem c:\windows\regedit.exe
SYSTEM user (On
Windows
7/8/Vista/2008),
which allows you to
view all hidden
system Registry
keys

System Requirements

This utility can work in all versions of Windows operating system: Windows 9x/ME, Windows NT,
Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008,
Windows 7, Windows 8, and Windows 10.

Versions History

Date Version Description


Fixed bug: elevate and other commands failed to work properly when
01/08/2019 2.86 there were many parameters after the command.

The runinteractive and runinteractivecmd commands now work


properly even if you don't run them from a Windows service.
23/06/2019 2.85 Fixed bug: The behvaiour of consolewrite command was unexpected
when there was '%' character.

Fixed to work again on Windows 98/2000.


22/04/2019 2.84

Added runinteractive and runinteractivecmd commands, which


allows you to run a process or NirCmd command that accesses the
GUI from a Windows service.
For example, if you try to use the savescreenshot command from a
Windows service, you'll get a black image, because NirCmd cannot
access the user interface from a Windows service.
19/04/2019 2.83
You can solve this problem with runinteractivecmd command:
nircmd.exe runinteractivecmd savescreenshot
"c:\temp\screenshot1.png"
Be aware that runinteractive and runinteractivecmd commands only
work from a Windows service ('SYSTEM' user).

Fixed the savescreenshot or savescreenshotfull commands to work


22/03/2019 2.82 properly with DPI scaling.

Fixed bug: NirCmd failed to execute the cmdwait, loop and a few
23/05/2016 2.81 other commands after qboxcom and qboxcomtop commands.

Fixed bug: clipboard readfile failed to read the last character of Ascii
file.
Added writeufile and addufile to clipboard command, for writing
30/01/2016 2.80
files in Unicode.
Fixed the restartexplorer command to work properly on Windows 10.

Added new commands: moverecyclebin, suspendprocess ,


resumeprocess.
Added etitle option to the find parameter of win command.
10/08/2013 2.75
'clipboard readfile' command now reads Unicode files (UTF-8 and
UTF-16).

29/10/2012 2.71 Added runassystem command, which allows you to run a process
with SYSTEM user (Works on Windows 7/8/Vista/2008)

Added new option to speak command: You can now save the entire
speach into a .wav file that can be played with any media player
(Instead of playing it directly to your sound card).
Added restartexplorer command, which simply restarts Windows
Explorer gracefully.
Added screensavertimeout command, which allows you to set the
screensaver timeout, in seconds.
12/09/2012 2.70 Added togglemax, togglemin, togglehide, toggledisable actions to
win command.
Added SystemSounds support for setappvolume, changeappvolume,
and muteappvolume commands.
Fixed issue on Windows 7: 'win close alltopnodesktop' command
caused a shutdown dialog-box to appear.
Fixed the setprimarydisplay to work properly.

Added setdefaultsounddevice command (for Windows 7/Vista/2008


only), which allows you to set the default sound device.
Added setsubunitvolumedb command (for Windows 7/Vista/2008
only), which allows you to set the volume of sound device subunits
28/06/2011 2.65 (Line In, Microphone, and so on)
Added mutesubunitvolume command (for Windows 7/Vista/2008
only), which allows you to mute/unmute the volume of sound device
subunits (Line In, Microphone, and so on)

Added mediaplay command for playing audio file (.mp3, .wav, and
so on) for the specified number of milliseconds.
21/06/2011 2.60 Added changebrightness and setbrightness commands for setting the
screen brightness on laptops and netbook computers.

On savescreenshot, savescreenshotfull, and savescreenshotwin


commands, you can now specify *clipboard* as a filename, in order
to save the screenshow into the clipboard
On savescreenshot command, you can now specify a rectangle to
08/06/2011 2.55 capture as x, y, width, and height instead of capturing the entire
screen.
Fixed savescreenshotfull command to work properly on multiple
screen system with negative coordinates.

Added 'runas' command, which allows you to run a new process with
the specified user name/password.
27/03/2011 2.52 Added 'Flash' action to the win command, with allows you to flash
the specified window.

Added 'focused' option for setappvolume, changeappvolume, and


muteappvolume commands, which allow you to easily change the
volume of the application that is currently in focus, on Windows
7/Vista/2008.
13/03/2011 2.51 Added 'default_record' option for setsysvolume, changesysvolume,
setsysvolume2, changesysvolume2, and mutesysvolume commands,
which allows you set easily change the volume of default recording
device, on Windows 7/Vista/2008.

Added 3 new sound volume commands to change or mute application


volume on Windows 7/Vista/2008: setappvolume, changeappvolume,
muteappvolume
24/02/2011 2.50 Added new information command that shows you a message box
with all sound devices on your Windows 7/Vista/2008 system:
showsounddevices.
22/02/2011 2.48 Fixed the problems with the timeout of the tray balloon in
trayballoon command.

Fixed bug: The sendkeypress command didn't work properly with


20/01/2011 2.47 Fxx keys (F1, F2, and so on).

Added option to locate window by process in win command.


Added max and min options (Minimized and maximized windows)
28/11/2010 2.46 into exec and exec2 commands.
Added x64 builds of nircmd.exe and nircmdc.exe

Added trayballoon command - displays a tray balloon with your


desired text and icon.
Added sendkeypress command - Alternative to the sendkey
command. Allows you to send key press combination in much easier
way, for example: sendkeypress ctrl+shift+esc
Added clonefiletime command to clone the date/time of existing file
into one or more files.
18/10/2010 2.45 Added setconsolemode command to set the console display mode -
window or full screen.
Added setconsolecolor command to set the foreground and
background colors of the console text.
Added consolewrite command to write text into the console window.
Added debugwrite for writing text into the debug output.
Added ~$folder.mydocuments$ variable.

Fixed a bug in elevate command: when running a program without


21/02/2010 2.41 parameters, NirCmd sent the elevate command string as a parameter
of the program.

Added elevate and elevatecmd commands to run and execute


commands with administrator rights under Windows 7/Vista/2008.
Added monitor parameter to setdisplay command, for using it with
multiple monitors.
Added setprimarydisplay command.
16/02/2010 2.40 Added folder.programfiles and folder.common_programfiles
variables.
Added async_off, async_on, async_low for monitor command. You
can try them if NirCmd.exe remains in memory when you use
monitor on/off command.

Improved the help .chm file - Now it contains a link to every


command.
Added help command - Automatically opens the reference of the
26/05/2009 2.37 desired command in http://nircmd.nirsoft.net. For example, if you
type 'nircmd.exe help speak', the reference page of speak command -
http://nircmd.nirsoft.net/speak.html will be opened in your default
browser.

Fixed bug in script: Sometimes the last line in the script was not
19/05/2009 2.36 executed properly.

Added loop command - execute a command multiple times.


Added currtime and currdate variables.
waitprocess - Added option to execute a NirCmd command after the
20/04/2009 2.35
process was closed.
Added rem (or ;) command, just for adding remarks in a script.

01/04/2009 2.30 Added speak command - Speaks the contents of the text or file that
you specify, by using the Speech library (SAPI) that comes with
Windows XP and Windows Vista.
Added savescreenshotfull command.

New actions for clipboard command - loadclp and saveclp (load/save


02/02/2009 2.25 in Windows .clp format)
New command: setprocessaffinity

New commands: waitprocess, setprocesspriority, qboxtop,


qboxcomtop.
01/01/2009 2.20 New action in clipboard command: copyimage (Copy image file to
the clipboard)

25/06/2008 2.15 New commands: setcursorwin, savescreenshotwin, filldelete

New commands: shellcopy, savescreenshot


12/04/2008 2.10

New commands: shellrefresh, convertimage, convertimages


09/02/2008 2.05 New option in clipboard command - saveimage

All sound volume commands and monitor command now works


under Vista.
16/06/2007 2.00 New commands: dlg, dlgany, sendkey, sendmouse, returnval
New actions in win command - dlgclick, dlgsettext, dlgsetfocus

New command: cmdshortcutkey


24/07/2006 1.85

Starting from this version, if you don't specify a sound device index
in setsysvolume, changesysvolume, setsysvolume2,
changesysvolume2 and mutesysvolume commands, the default sound
15/07/2006 1.84
device in control panel ("preferred device") is used.
New find options in win command: active, foreground, desktop

Fixed bug with parameter variables: parameter dialog-box appear


20/05/2006 1.83 more than once.
New find option in Win command: alltopnodesktop

New win actions: postmsg and sendmsg.


18/02/2006 1.82 New command: closeprocess
NirCmd now returns a non-zero value on error.

New command: emptybin - Empty the Recycle Bin.


New optional parameter in setdisplay command: refresh rate.
19/11/2005 1.81 rashangup command without parameter - disconnect all active
connections.

New commands: exec2, cmdwait.


New options in clipboard command.
Volume commands (setsysvolume, changesysvolume, setsysvolume2,
24/09/2005 1.80
changesysvolume2, mutesysvolume) now allows you to change the
volume of non-default sound card.

New win actions: activate, hideshow, +style, -style, +exstyle, -exstyle


New commands: movecursor, setcursor.
07/07/2005 1.70 New command: setfilefoldertime - allows you to change the
date/time of folders, under Windows 2000/XP only.
10/06/2005 1.62 New actions in win command: focus, enable, disable

new command: sysrefresh - make a general system refresh after


26/05/2005 1.61 modifying your system settings in the Registry.

New paramsfile command: Allows you to execute a command


multiple times by loading the parameters from a text file.
New actions in win command: move, center, settext.
New 'child' action in win command: Allows you to move/hide child
07/05/2005 1.60 windows (For example: the start button in the system tray)
New clipboard command: Allows you to put a string in the clipboard,
and clear the clipboard.
New gac command: Allows you to install assemblies in Global
Assembly Cache.

New variable: ~$clipboard$ - paste the text that you copied to the
clipboard into the command-line.
Parameter variables: ~$param.ParamName$ - Display an input
28/12/2004 1.56
window for typing the text that you want insert into the command-
line.

07/12/2004 1.55 Added RegEdit command.


On reg commands (regsetval, regdelval, regdelkey), you can now
also use the following abbreviated key name: HKCU for
HKEY_CURRENT_USER, HKLM for
18/11/2004 1.54 HKEY_LOCAL_MACHINE, HKCR for HKEY_CLASSES_ROOT,
HKU for HKEY_USERS, HKCC for HKEY_CURRENT_CONFIG.
redraw action for win command.

03/11/2004 1.53 Fixed 'monitor off' problem in XP SP2.

rasapi32.dll is now loaded only when using the dial commands (rasdial,
09/10/2004 1.52 rasdialdlg, rashangup). In previous versions, NirCmd was statically linked
to rasapi32.dll, and that caused problems in old NT systems.

Variable names are now enclosed with '$' char instead of '%' char.
I made this change because the '%' char causes problems when running
29/09/2004 1.51
NirCmd from cmd/bat file. using the '%' char for variable names is still
supported for backward compatibility.
New commands: cmdshortcut, regsvr, mutesysvolume,
changesysvolume, changesysvolume2, setsysvolume2.
New actions in win command: trans, setsize, settopmost, ititle.
22/09/2004 1.50 New variables: folder.nircmd, nir.exefile
nircmdc.exe - console version of NirCmd.
Changed name - from NirComLime to NirCmd.

New commands: wait, setvolume, setsysvolume, execmd, exec.


New commands for executing NirCmd on remote machines: remote
and multiremote.
05/05/2004 1.40 Folder and system variables.
New option in setfiletime command - set the file time to the current
time (now parameter)
New parameter in shortcut command - hot key.

New commands: qboxcom, beep, stdbeep, cdrom, urlshortcut,


monitor, screensaver, standby, and hibernate.
01/03/2004 1.30
Fixed the bug with ~x string sequences.

08/01/2004 1.20 New commands: setdialuplogon, script


Special string sequences (~q, ~t, ~n and so on) to allow you to embed
quotes and new line characters into the parameters of any command.

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 !

View NirCmd Full Help File

Download NirCmd

Download NirCmd 64-bit

You might also like