{"id":1006,"date":"2010-02-24T10:28:28","date_gmt":"2010-02-24T04:58:28","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=1006"},"modified":"2019-06-24T18:38:10","modified_gmt":"2019-06-24T18:38:10","slug":"nircmd-elevate-switch-useful-uses","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/nircmd-elevate-switch-useful-uses\/","title":{"rendered":"NirCmd Elevate Switch Added &#8211; Some Useful Uses"},"content":{"rendered":"<p>We&#8217;ve covered the excellent multi-purpose command-line tool NirCmd from Nirsoft <a href=\"http:\/\/www.google.com\/search?q=nircmd+site:winhelponline.com\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">earlier<\/a>. This post talks about the new command-line switches added in the current version of NirCmd. Earlier this month, I sent a NirCmd feature request to Nir Sofer, asking to include an &#8220;elevate&#8221; switch, which should launch an application elevated (Windows Vista, Windows 7 &amp; 2008.) Nir was kind enough to incorporate this feature in the immediate version update (v2.40). Later another update, to fix a bug I reported, v2.41 was released.<!--more--><\/p>\n<p>NirCmd v2.40 and higher includes the &#8220;elevate&#8221; and &#8220;elevatecmd&#8221; switches to run and execute commands with administrator rights under Windows 7\/Vista\/2008. Here are some useful uses of this all-in-one tool.<\/p>\n<p><i>Of course, you&#8217;ll see the User Account Control elevation dialog when you use NirCmd with &#8220;elevate&#8221; or &#8220;elevatecmd&#8221; switches. There is no way bypassing that without disabling UAC or without relaxing UAC settings.<\/i><\/p>\n<h2>Launch an application elevated (&#8220;Run as Administrator&#8221;)<\/h2>\n<p>To launch an application, say Notepad as administrator, use the following shortcut\/command from the Run dialog:<\/p>\n<pre>nircmd elevate notepad.exe<\/pre>\n<p>or by including the full path:<\/p>\n<pre>nircmd elevate c:\\windows\\system32\\notepad.exe<\/pre>\n<p>If the path contains spaces, enclose the path within double-quotes. For example:<\/p>\n<pre>nircmd elevate \"C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe\"<\/pre>\n<h2>Launch an application elevated &amp; Passing a parameter<\/h2>\n<p>IMO, this is probably the most needed thing in Windows 7 &amp; Windows Vista. Windows allows you to run an application elevated by right-clicking the shortcut or executable, and choosing &#8220;Run as Administrator&#8221;. However, there is no option to pass a parameter to the elevated application.<\/p>\n<p><b>Example #1 &#8211; Edit the HOSTS file<\/b><\/p>\n<p>To create a shortcut to edit the HOSTS file (you&#8217;ll have to elevate the editor in order to write to HOSTS), you use this command:<\/p>\n<pre>nircmd elevate Notepad \"C:\\Windows\\System32\\Drivers\\Etc\\HOSTS\"<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/archived\/nircmd-elev-3.jpg\" \/><\/p>\n<p><b>Example #2 &#8211; Register or Unregister a DLL<\/b><\/p>\n<p>Want to register\/unregister a DLL or OCX file quickly, without having to open the Command Prompt (as Administrator) first? Use this command from Start\/Run:<\/p>\n<pre>nircmd elevate regsvr32 c:\\windows\\system32\\jscript.dll<\/pre>\n<p><b>Example #3 &#8211; Take Ownership of a File or Folder<\/b><\/p>\n<p>To Take Ownership of a folder, use:<\/p>\n<pre>NirCmd elevate cmd \/k takeown \/f &lt;foldername&gt; \/r \/d y<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/archived\/nircmd-elev-1.jpg\" \/><\/p>\n<p>Followed by ICacls to assign Permissions.<\/p>\n<pre>NirCmd elevate cmd \/k icacls &lt;foldername&gt; \/grant administrators:F \/T<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/archived\/nircmd-elev-2.jpg\" \/><\/p>\n<p>(<i>Usage of TakeOwn and ICacls for files\/folders are explained in our article <a href=\"https:\/\/www.winhelponline.com\/blog\/take-ownership-of-file-or-folder\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Take Ownership of a file or folder using command-line in Windows<\/a>.<\/i>)<\/p>\n<p><b>Example #4 &#8211; Open an Elevated Command Prompt at a Specified Folder<\/b><\/p>\n<p>When you open an elevated Command Prompt using Start menu or using the Command Prompt shortcut, the default start directory is C:\\Windows\\System32. You use the CD command to change to a different directory. Using NirCmd, you can open an elevated Command Prompt window mentioning the start directory (say D:\\Test, in this example).<\/p>\n<pre>nircmd elevate cmd.exe \/k cd \/d \"D:\\Test\"<\/pre>\n<h2>The &#8220;Elevatecmd&#8221; Switch<\/h2>\n<p>As noted earlier, there is also an <b>elevatecmd<\/b> switch added to NirCmd. Note that this is different from the command-line switch <b>elevate.<\/b> The <b>elevatecmd<\/b> switch runs a <b>NirCmd command <\/b>(internal commands of NirCmd) with administrator rights.<\/p>\n<p><b>Writing to the Registry using NirCmd<\/b><\/p>\n<p>Writing to HKEY_LOCAL_MACHINE requires elevation, and you&#8217;ll have to use <b>elevatecmd<\/b> if you&#8217;re using NirCmd&#8217;s &#8220;regsetval&#8221; switch to write to a registry value.<\/p>\n<pre>NirCmd elevatecmd regsetval sz \"HKLM\\Software\\Test\" \"Value1\" \"test-data\"<\/pre>\n<p>This writes the data &#8220;test-data&#8221; under the registry value &#8220;Value1&#8221; in the above registry key.<\/p>\n<p><i>Download <a href=\"http:\/\/www.nirsoft.net\/utils\/nircmd.html\" target=\"_blank\" rel=\"noopener noreferrer\">NirCmd<\/a> &#8211; Windows command line tool from NirSoft. Refer to <a href=\"http:\/\/nircmd.nirsoft.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">NirCmd Command Reference Guide<\/a> as well, to make the most of this tool.<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve covered the excellent multi-purpose command-line tool NirCmd from Nirsoft earlier. This post talks about the new command-line switches added in the current version of NirCmd. Earlier this month, I sent a NirCmd feature request to Nir Sofer, asking to include an &#8220;elevate&#8221; switch, which should launch an application elevated (Windows Vista, Windows 7 &amp; &#8230; <a title=\"NirCmd Elevate Switch Added &#8211; Some Useful Uses\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/nircmd-elevate-switch-useful-uses\/\" aria-label=\"Read more about NirCmd Elevate Switch Added &#8211; Some Useful Uses\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[6],"tags":[],"class_list":["post-1006","post","type-post","status-publish","format-standard","hentry","category-utilities"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":425,"url":"https:\/\/www.winhelponline.com\/blog\/run-bat-files-invisibly-without-displaying-command-prompt\/","url_meta":{"origin":1006,"position":0},"title":"How to run .BAT files invisibly, without displaying the Command Prompt window","author":"Ramesh","date":"August 5, 2008","format":false,"excerpt":"Batch files (.BAT) and Windows NT Command Script (.CMD) files run in console window when double-clicked. This means that the Command Prompt window will be visible until the .BAT or .CMD file execution is complete. To make .BAT or .CMD file execution less intrusive, you can configure it to run\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"run batch file hidden - nircmd exec","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/08\/nircmd-batch-file-hidden.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3369,"url":"https:\/\/www.winhelponline.com\/blog\/start-snipping-tool-capture-mode-default\/","url_meta":{"origin":1006,"position":1},"title":"How to Make Snipping Tool Default to New Snip when Launched","author":"Ramesh","date":"June 28, 2016","format":false,"excerpt":"Snipping Tool is a handy screenshot tool included in Windows Vista and higher, with the annotation feature. Running Snipping Tool in Windows Vista and 7 would start the utility in capture mode (New rectangular snip) automatically, but this has changed in Windows 8 and Windows 10. In Windows 8 and\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/06\/w10-snipping-tool-mode-menu.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3704,"url":"https:\/\/www.winhelponline.com\/blog\/windows-sleep-hibernate-mode-command-line\/","url_meta":{"origin":1006,"position":2},"title":"Put Windows Into Sleep or Hibernate Mode Using Command-line","author":"Ramesh","date":"August 6, 2016","format":false,"excerpt":"If you frequently use the Sleep or Hibernate feature in Windows, you can create and pin a shortcut to the Taskbar to put your computer to sleep or hibernate mode in a single click, without having to open the Start menu. Here is how to do that. Put Windows to\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":890,"url":"https:\/\/www.winhelponline.com\/blog\/add-nircmd-speak-to-context-menu-text-files\/","url_meta":{"origin":1006,"position":3},"title":"Fun Tip: Add &#8220;Speak&#8221; Option to the Context Menu for Text Files","author":"Ramesh","date":"April 8, 2009","format":false,"excerpt":"The amazing NirCmd utility now has a new \"speak\" command that allows you to easily cause your computer to speak the text that you wish. In this command, NirCmd uses the Speech library (SAPI) that is installed in Windows. Here is a fun tip on how to add the Speak\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/archived\/nircmd-speak.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1071,"url":"https:\/\/www.winhelponline.com\/blog\/run-program-elevated-right-click-menu-windows\/","url_meta":{"origin":1006,"position":4},"title":"How to Add a Right-Click Menu Option to Run a Program Elevated","author":"Ramesh","date":"August 18, 2010","format":false,"excerpt":"From the Windows Taskbar, you can start a program elevated by holding the Ctrl & Shift keys and then clicking on a pinned shortcut. To launch a program elevated from the right-click menu, you can add custom entries and launch it using a script or using the NirCmd utility. Earlier\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"take ownership right-click menu","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/09\/take_ownership_context_menu.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4543,"url":"https:\/\/www.winhelponline.com\/blog\/launch-alt-tab-switcher-script-command-line-mouse\/","url_meta":{"origin":1006,"position":5},"title":"Create Shortcut to Launch the Alt-Tab Switcher (for Mouse users)","author":"Ramesh","date":"November 17, 2016","format":false,"excerpt":"The most useful and frequently used Alt + Tab keyboard shortcut has been there since the Windows 3.1 era. If you're are primarily a mouse user and want to open the Alt + Tab switcher screen using shortcut or script, this post tells you how to do that in Windows\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"launch alt-tab switcher using shortcut","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/switcher-0.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/1006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=1006"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/1006\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=1006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=1006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=1006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}