#RequireAdmin
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <LocalSecurityAuthority.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <Misc.au3>
$ok = RegRead("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell\MyMenu","SubCommands")
If Not @OSVersion = "WIN_7" Then Exit
If _Singleton(" Win7桌面右键中添加菜单", 1) = 0 Then Exit
Dim $szDrive, $szDir, $szFName, $szExt
Opt("TrayIconHide", 1)
GUICreate(" Win7桌面右键中添加菜单", 320, 110)
$RegName = GUICtrlCreateInput("", 10, 5, 210, 20)
$FileName = GUICtrlCreateInput("", 10, 35, 210, 20)
$test = GUICtrlCreateInput($ok, 10, 65, 210, 20)
$btn = GUICtrlCreateButton("打开文件", 250, 5, 60, 20)
$btn2 = GUICtrlCreateButton("添加菜单", 250, 35, 60, 20)
$MyMenu = "MyMenu"
GUISetState()
$msg = 0
While 1
$msg = GUIGetMsg()
Select
Case $msg = $btn
$var = FileOpenDialog("选择文件", @ProgramFilesDir & "", "程序 (*.exe)", 1)
$arrPath = _PathSplit($var, $szDrive, $szDir, $szFName, $szExt)
GUICtrlSetData($RegName, $var)
GUICtrlSetData($FileName, $szFName)
Case $msg = $btn2
$read = GUICtrlRead($FileName)
$RegName2 = GUICtrlRead($RegName)
If StringRight($RegName2, 4) <> ".exe" Then
MsgBox(16, "错误", "指定的文件不是程序!", 3)
ContinueLoop
EndIf
If Not FileExists($RegName2) Then
MsgBox(16, "错误", "指定的文件不存在!", 3)
ContinueLoop
EndIf
If $RegName2 = '' Or $read = '' Then
ContinueLoop
Else
If Not FileExists(@WindowsDir & "\Windows.ico") Then FileInstall("Windows.ico", @WindowsDir & "\Windows.ico")
RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "Position", "REG_SZ", "Bottom")
RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "Icon", "REG_EXPAND_SZ", @WindowsDir & "\Windows.ico,0")
$SubCommand = RegRead("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands")
$result = StringInStr($SubCommand, $read)
If $result = Not 0 Then
MsgBox(16, "错误", "有同名菜单!", 3)
ContinueLoop
EndIf
If $SubCommand = "" Then
RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands", "REG_SZ", $read)
Else
RegWrite("HKEY_CURRENT_USER\Software\Classes\DesktopBackground\shell" & $MyMenu, "SubCommands", "REG_SZ", $SubCommand & ";" & $read)
EndIf
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "MUIVerb", "REG_EXPAND_SZ", $read)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "Icon", "REG_EXPAND_SZ", $RegName2 & ",0")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read & "\command", "", "REG_EXPAND_SZ", $RegName2)
RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell" & $read, "MUIVerb")
If @error = 1 Then
MsgBox(16, "", "添加失败!", 3)
Else
MsgBox(0, "", "添加成功!", 3)
IniWrite(@ScriptDir & "\MyMenu.ini", "Config", $read, "")
EndIf
GUICtrlSetData($RegName, '')
GUICtrlSetData($FileName, '')
EndIf
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
代码如上,是引用站内一位朋友的