Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!
Showing posts with label elevated command. Show all posts
Showing posts with label elevated command. Show all posts

Thursday, September 8, 2011

Add elevated command prompt to context menu

Source 
I would like to add to my context menu an elevated command prompt (with administrator privileges) in the same or similar coding fashion (not binary code) as in this example below. The key is that it has to be "elevated" with Administrator privileges, not just a normal command prompt to open. I am not sure how to write a working script since it "MAY" (probably is) quite different than the coding pattern in my example here after including the 'elevated' coding component part to it:
[HKEY_CLASSES_ROOT\Directory\Background\shell\Elevated Command Prompt]
[HKEY_CLASSES_ROOT\Directory\Background\shell\Elevated Command Prompt\command]
@="control appwiz.cpl"
Please correct by adding and or deleting or modifying the script above so the code that would demonstrate a working "elevated" command prompt script to open in a window.
I would also like to add the command prompt icon to my context menu too. I am very sure that it would look something like this (pretty sure if the registry key information is correct though, probably it is not since I am looking for the script to be 'elevated' as I have already stated):
[HKEY_CLASSES_ROOT\Directory\Background\shell\Elevated Command Prompt]
"Icon"="C:\\Windows\\Context Menu Icons\\Elevated Command Prompt.ico"
Where an "Elevated Command Prompt" ico icon in a "Context Menu Icons" folder would be FIRST placed in the C:\Windows folder location BEFORE running a workable elevated command prompt registry script.
So what is the proper coding I need to do (and appropriately placed in this script) in order to add an elevated command prompt with the icon to this script so it works in the context menu???
sevenforums.com/tutorials/47415-open-command-window-here-administrator
1. To Add "Open Command Window Here as Administrator"
A) Click on the download button below to download the file below.
Add_Open_Command_Window_Here_as_Administrator.reg
download
B) Go to step 3.
2. To Remove "Open Command Window Here as Administrator"
A) Click on the download button below to download the file below.
Remove_Open_Command_Window_Here_as_Administrator.reg
download
3. Click on Save, and save the .reg file to the desktop.
4. Right click on the downloaded .reg file and click on Merge.
5. When prompted, click on Run, Yes, Yes, and OK to approve merging the .reg file.
6. You can now delete the downloaded .reg file if you like.
 

Saturday, February 27, 2010

Elevated Command Prompt

Source::
How to open an elevated Command Prompt in Windows Vista

(Fig 1) Elevated Command PromptNote the word Administrator in the Window title.

(Fig 2) Command Prompt (normal)

Summary

With the User Account Control (UAC) enabled by default in Windows Vista, you'll need to use an elevated Command Prompt whenever you need to do some administrative tasks from Command Prompt. For example, running regsvr32.exe command to register or unregister an DLL/ActiveX, launching a batch file or script requiring administrative privileges, and other tasks require you open an elevated Command Prompt. Elevated Command Prompt runs under administrative privileges.
This article describes different ways to open an elevated Command Prompt window.

Open an elevated Command Prompt window

Method 1

Click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator.

Method 2

Click Start, type cmd.exe When the Instant search results are shown, right-click the cmd.exe entry and choose Run as administrator. Or using keyboard, select the cmd.exe in the Instant search results using the UP/DOWN arrow and press CTRL+SHIFT+ENTER on the keyboard. CTRL+SHIFT+ENTER runs a program elevated, but only works when using the Instant Search feature in the Windows Vista Start menu.

Method 3

Create a new desktop shortcut to CMD.EXE. Right-click on the shortcut and choose Run as administrator. To run the shortcut as an administrator by default, right-click the Command Prompt shortcut you created on the Desktop, and choose Properties. In the Shortcut tab, click Advanced. Place a checkmark near Run as administrator. Click OK and OK. Now, every time when you double-click the shortcut Command Prompt window will open elevated. You'll see the consent or the confirmation prompt anyway.
Note: If you're a frequent user of the Command Prompt, you can Pin it to the Start menu as well, and/or send a shortcut to the Quick Launch folder for easy reach.
Method 4
Apply the tweak I suggest in article How to open an elevated Command Prompt from the folder context menu in Windows Vista so that you can open an elevated Command Prompt from the context menu of a folder. The tweak adds the special runas verb to launch Command Prompt elevated. It adds an Open Command Prompt here (Administrator) option in the context menu for folders and Computer (formerly, My Computer). Here are the screenshots:
       
Click Start, click All Programs, click Accessories, right-click Command Prompt, and then click.
Note: You'll be prompted for a confirmation or administrator credentials when a program is run elevated. When you are prompted for an administrator password or for confirmation, type your password, or click Continue.

Friday, February 26, 2010

NirCmd Elevate Switch

Source
Download & Info
We’ve covered the excellent multi-purpose command-line tool NirCmd from Nirsoft several times before. 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 "elevate" switch, which should launch an application elevated (Windows Vista, Windows 7 & 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.
NirCmd v2.40 and higher includes the "elevate" and "elevatecmd" 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.
Of course, you’ll see the User Account Control elevation dialog when you use NirCmd with "elevate" or "elevatecmd" switches. There is no way bypassing that without disabling UAC or without relaxing UAC settings.

Launch an application elevated ("Run as Administrator")

To launch an application, say Notepad as administrator, use the following shortcut/command from the Run dialog:
nircmd elevate notepad.exe
or by including the full path:
nircmd elevate c:\windows\system32\notepad.exe
If the path contains spaces, enclose the path within double-quotes. For example:
nircmd elevate "C:\Program Files\Windows NT\Accessories\wordpad.exe"

Launch an application elevated & Passing a parameter

IMO, this is probably the most needed thing in Windows 7 & Windows Vista. Windows allows you to run an application elevated by right-clicking the shortcut or executable, and choosing "Run as Administrator". However, there is no option to pass a parameter to the elevated application.
Example #1 – Edit the HOSTS file
To create a shortcut to edit the HOSTS file (you’ll have to elevate the editor in order to write to HOSTS), you use this command:
nircmd elevate Notepad "C:\Windows\System32\Drivers\Etc\HOSTS"
Example #2 – Register or Unregister a DLL
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:
nircmd elevate regsvr32 c:\windows\system32\jscript.dll
Example #3 – Take Ownership of a File or Folder
To Take Ownership of a folder, use:
NirCmd elevate cmd /k takeown /f /r /d y
Followed by ICacls to assign Permissions.
NirCmd elevate cmd /k icacls /grant administrators:F /T
(Usage of TakeOwn and ICacls for files/folders are explained in our article How to Take Ownership of a file or folder using command-line in Windows 7 and Vista.)
Example #4 – Open an Elevated Command Prompt at a Specified Folder
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).
nircmd elevate cmd.exe /k cd /d "D:\Test"

The "Elevatecmd" Switch

As noted earlier, there is also an elevatecmd switch added to NirCmd. Note that this is different from the command-line switch elevate. The elevatecmd switch runs a NirCmd command (internal commands of NirCmd) with administrator rights.
Writing to the Registry using NirCmd
Writing to HKEY_LOCAL_MACHINE requires elevation, and you’ll have to use elevatecmd if you’re using NirCmd’s "regsetval" switch to write to a registry value.
NirCmd elevatecmd regsetval sz "HKLM\Software\Test" "Value1" "test-data"
This writes the data "test-data" under the registry value "Value1" in the above registry key.
Download NirCmd – Windows command line tool from NirSoft. Refer to NirCmd Command Reference Guide as well, to make the most of this tool