Quickly create a custom file, right-click it, and run the command prompt menu as an administrator.

Source: Internet
Author: User

Quickly create a custom file, right-click it, and run the command prompt menu as an administrator.

  

Most Windows users use the default file formats created by right-clicking. This may be inconvenient for people we love or have special requirements. For example, to create a file in the format of. reg. bat. vbs, you need to create a new text file and change the suffixOr save it through the corresponding softwareFor. reg. bat. vbs. Is it a little troublesome? Can I add the desired file type to the new option in the right-click menu. In a Windows environment, there is no problem.

The Regedit Registry is a fun and powerful thing in Windows. Registry (a logon file in the Traditional Chinese version of Windows) is an important database in Microsoft Windows, used to store system and application settings. It is a core of Windows systems. In short, the settings are associated with many UI interaction interfaces we are exposed, for example, you can choose to remove the small arrow of the shortcut icon and the small shield of the Administrator identity. For example, this article adds the file format of the new option.

For example, to add a Bat batch file in the right-click Create option, run the following two commands at the (Administrator) command prompt. This command prompt must have administrator privileges or insufficient permissions. Right-click the command prompt in the Windows system or attachment file in the Start menu and run it as administrator, if you log on to the system's built-in Administrator Account Administrator, you can directly open the account and determine whether the account is Administrator. You can use the title bar to determine whether the account is Administrator. If it is marked with Administrator: C: \ WINDOWS \ system32 \ cmd.exe.

The following commands are case-sensitive. A specific letter is capitalized only for the sake of appearance and consistency with the system settings, you can run the first command. Right-click the new option and the file type for Windows batch processing will be available. The second command should be to modify the name displayed for the option, however, the author tried to make no use.

 

reg add "HKCR\.bat\ShellNew" /v NullFile /t REG-SZ /d "" /freg add "HKCR\.bat\ShellNew" /v FileName /t REG_EXPAND_SZ /d "" /f

 

  For a brief explanation of the command, HKCR is short for HKEY_CLASSES_ROOT, one of the five main directory trees in the registry. This directory is necessary for running the program, and the other four items are not described in detail, for details, refer to Baidu. The following parameters are like/f/v/d. You can enter reg add/? In the command prompt /? For more information, HKCR \. shellNew in bat \ ShellNew is the name of the new item, of course, it is not as simple as the name, it is to determine whether the file type is in the right-click Create option, there is a string value under the name of NullFile. REG-SZ is to indicate the string value REG_EXPAND_SZ is to indicate that the string value can be expanded more than the two there are eight about it is not detailed. The following "" indicates the value of the string corresponding to the previous one. It is null.

Right-click the job and select the Windows batch processing option you just added. You can. bat is replaced with the suffix you need to add, such. vbs. html. c. cpp. reg. js. cmd and so on. If you want to write it correctly, it will become a junk data in the registry.

Of course, people who love to do so won't be able to perform this dark operation. You can run the regedit command or the software Registry Workshop to enter the Registry and modify it. start with the extension name in the file format in Windows. Expand the new item named ShellNew and create a string value named NullFile in this item (that is, in the right box. (Tips: enter letters or text like in the resource manager to locate the corresponding folder, on the premise that the located content is in the active state and the mouse is activated) similarly, we can use this method to clear redundant or uncommon file formats. For example, in Windows 7, we can find the suffix corresponding to the ShellNew item Delete contact option under Briefcase. the suffix of the contact diary option. jnt. The options for Windows 7 8 10 are not the same, and some suffixes may be different. (Reminder: to prevent unnecessary losses, back up the registry before deleting the registry key)

Next, we can see that these VBSFILE batfile regfile and so on are all corresponding file format extensions. What is the connection? Let's take a look at shell shellex open command, you can probably guess how it should be opened. Then, let's take a look at the value of the string in the command item as "% SystemRoot % \ System32 \ WScript.exe" "% 1" % *. the default file type opening method may be associated. Other tasks such as Edit Print runas are related to editing, printing, and running identities. For more information, I don't know much about them. If you have a hard time playing, however, I don't care if the system crashes due to improper operations ~ I think it is wise to back up the registry before I try again.

The following describes how to add the command prompt option as administrator right-click. Run the command prompt. In Windows + R, Enter cmd and press the Enter key. Press Shift and right-click to open the Command Prompt window here, or search for it in the Start Menu. Otherwise, go to C: find the \ Windows \ System32 or C: \ Windows \ SysWOW64 directory. These are not problems when you log on to the system's built-in Administrator Account Administrator. You can directly open them as Administrator permissions. If not? Go to the Start Menu, find the command prompt, right-click the Administrator to run the command, or right-click the resource manager directory to run the command as the administrator. For example, if the built-in Administrator is not enabled, this method is applicable to Windows users who do not have the Built-in Administrator Account Enabled. Of course, you do not want to play it.

Above code:

 

Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT \ Directory \ Background \ shell \ runas] "icon" = "C: \ Windows \ System32 \ shell32.dll, 303 "@ =" Run command Prompt as administrator "" Extended "=" "[HKEY_CLASSES_ROOT \ Directory \ Background \ shell \ runas \ command] @ =" cmd.exe/t: 4f/s/k pushd \ "% V \""

Copy and paste it to a text file and save it. if reg is a registry file suffixed with reg, you can right-click the "Import Registry" command prompt named "Run as administrator" and Right-click it. What ??! Also press Shift? Don't rush to hear me coming slowly.

The first line is the Registry version declaration. Let the system know that this is a registry text file to be imported to the Registry, just like the html declaration. <! DOCTYPE html> similar to the above, this [HKEY_CLASSES_ROOT \ Directory \ Background \ shell \ runas] is the new item named runas under shell, runas is used to run as an administrator. You can view runas in other registry items, such as batfile in the preface, it should be right-click a file in this format, and the right-click operation means running as an administrator. However, there is no such field (right-click in the blank space). In this case, right-click the field and add the option to run the command prompt as an administrator, it is actually a normal startup command prompt, but we can run it as an administrator only through runas.

"Icon" = "C :\\ Windows \ System32 \ Shell32.dll, 303"

This is to set the icon style before the option, as shown in the personalization and display settings in the context menu, there is an icon in front of the option, you can delete this line without setting, followed by "C: \ Windows \ System32 \ Shell32.dll, 303 "indicates the icon path. Although Shell32.dll is a dynamic link library file, it contains more than 303 types of icons, and indicates the icon number, actually, something like Shell32.dll is a library of icons and imageres. dll imagesp1.dll (How do you know? The shortcut has the function of changing the icon, when you cannot match an icon, the system will automatically jump to select this file. The file Shell32.dll contains most icons. On the contrary, I found that the above two are less open, and many icons will be displayed for selection. this number is arranged according to the order of the icons. It takes some time to figure it out. Remember that when I was okay, I matched it and made a photo. I found it and then added it) these are not exactly the same in different Windows systems, because the newly released system must have many new icons and style numbers, which may also change. However, the new version of Windows includes icons in earlier versions. Like the Shell32.dll provided by the author, 303 is a moderate icon style in Windows 7 and a pair of checked members in Windows 10, but the correct icon should be imageres. in the dll file, there is an administrator icon at the command prompt NO. 263.

  @ = "Run Command Prompt as administrator" this option will name the option in the right-click to change the (default) Blank Value Under runas To Run Command Prompt as administrator, in the Windows registry, each item has A blank (REG_SZ) string value (default). You can also delete this line. In this case, the option name is run as Administrator () the system allocates the default name. How do you like it's up to you. After the modification, no bound buttons are available, but it should not be affected. Most of them are operated with the mouse.

"Extended" = "" indicates that the new value under the runas item is a blank string value named Extended. This is where the Shift key is located, if you delete this row, you do not need to press Shift and right-click it to view it. However, you can add this line if you do not want to right-click it to make it visible, this is similar to running a command prompt (Powershell is a more powerful and flexible tool in Windows 10) on Windows 7 by right-clicking Shift, after this option is added, right-click Shift and choose system from here to open the Command Prompt window/open the Powershell window here to appear in the options together with the one just added.

[HKEY_CLASSES_ROOT \ Directory \ Background \ shell \ runas \ command]

@ = "Cmd.exe/t: 4f/s/k pushd \" % V \""

Similar to the previous one, a new (default) Blank Value Under runas is set to cmd.exe/t: 4f/s/k pushd \ "% V \" named command, this option points to the path of the running file, that is, the command prompt cmd.exe. Cmd.exe is an executable file. The command prompt does not explain much. The following parameters can be used to run cmd /? For more information, see the parameters.

/T: 4f indicates the foreground color and background color of the open Command Prompt window. Here, the color is red and white. For more colors, run color/? In the Command Prompt window /? Learn more

Run the command specified by the/s string and terminate/k to execute the command specified by the string, but keep note that if you want to set the foreground color and background color, then/t: the 4f parameter must be added before/s/k. Otherwise, the setting is invalid and the prompt syntax is incorrect.

Pushd stores the current directory for use by the POPD command and then changes it to the specified directory. Go to https://technet.microsoft.com/zh-cn/library/cc771180 (v = ws.10). aspx for details

\ "% V \" \ is an escape character. If the escape "parameter is % V, the author does not know its meaning, but only displays commmand items under Powershell (default) the value of the blank value carries \ "% V \", so it is also added. Adding without adding is not a problem, but it is added to keep the formation ..

If you are unwilling to use the registry file to import and add such items, you can add them to the HKEY_CLASSES_ROOT \ Dirctory \ Background \ shell directory tree in the registry. Add the settings according to the code given above. There are many ways to play the Registry. If you are interested in it, you can play it on your own.

Finally, Let's remind you to back up the registry before you play. Right-click and select the registry of the master, and modify the Save name and address. This is to back up the entire registry. To back up an item, right-click it and choose export. In the recovery mode, open the backup registry file. reg and import it to the computer.

So, have a good time ~

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.