Najlepszym sposobem jest ustawienie Notepad ++ na działanie jako administrator. Problem polega na tym, że łamie opcję Kliknij prawym przyciskiem. Zrobiłem więc zamianę na opcję prawego kliknięcia, która usuwa poprzednią. Miłą częścią mojej poprawki jest dodanie jej do ustawienia Directory w Rejestrze. Teraz możesz kliknąć folder prawym przyciskiem myszy i wybrać opcję Edytuj za pomocą Notepad ++, a otworzy on wszystkie pliki w Notepad ++ :). Dużo programuję w VBScript. Ułatwia mi to edycję wszystkich moich plików i wprowadzanie globalnych zmian, kiedy wymyślam nową metodę zrobienia czegoś lub zmiany obiektu.
Mój VBScript tworzy kopię zapasową kluczy rejestru, zanim je zmieni. Nie ustawia Notepad ++ jako administratora, więc musisz to zrobić, klikając prawym przyciskiem myszy plik wykonywalny Notepad ++ i zmieniając go tak, aby działał jako administrator. Zaczynam szukać, jak sprawić, by działał jako administrator. Kiedy to wymyślę, zmodyfikuję mój post, aby umożliwić Ci edycję jako Administrator lub normalną edycję.
'==========================================================================================
' NAME: New-OpenWithNotepad++(WinVista7).vbs
' EDITED: Kevin Dondrea , Gordos-Dondrea Enterprises and Foundation
' DATE : 8/12/2012
' COMMENT: This script Exports Registry keys and replaced Notepad++ Right Click options.
' Works with Windows Vista and 7. Also works for restricted Win XP accounts.
' WEB LINK:
'==========================================================================================
Option Explicit
' =============== START ADD ADMIN RIGHTS ===============
' This adds the Admin Run Function for Windows Vista and 7
' You must put this at the top below computer and End If at the
' very end of the script
If WScript.Arguments.length = 0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "WScript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Else
' Do not forget to add End If at the end of the script
' =============== END ADD ADMIN RIGHTS ===============
On Error Resume Next
' =============== START CONSTANT VARIABLES ===============
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
' =============== END CONSTANT VARIABLES ===============
' =============== START DIM VARIABLES ===============
Dim objFSO, objWrite2File, objShell, objReg, objRegistry, objWshShell
Dim strDate, strTime, strTime2, strFileName, strOpenFile
Dim strComputer, strCommand, strHostName, strUserName
Dim intRC, strKeyPath, strValueName, strValue
' =============== END DIM VARIABLES ===============
' --------------------------------------------------------------------------
' =============== START COMPUTER NAME, TIME and DATE ===============
strComputer = "."
' Reads registry for Computer Name
Set objShell = CreateObject("WScript.Shell")
' Edit or Add with Registrry Object
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
' Same as above but used only to delete registry key
Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strHostName = objShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\" & _
"Tcpip\Parameters\Hostname")
strUserName = objShell.RegRead ("HKLM\SOFTWARE\Microsoft\Windows NT\" & _
"CurrentVersion\Winlogon\DefaultUserName")
' Retreives Date and Time
strTime = Right("0" & Hour(now()), 2) & Right("00" & _
Minute(Now()), 2) & Second(Now())
strTime2 = Right("0" & Hour(now()), 2) & ":" & Right("00" & ":" & _
Minute(Now()), 2) & ":" & Second(Now())
strDate = Right("0" & Month(now()), 2) & "-" & Right("00" & _
Day(Now()), 2) & "-" & Year(Now())
' -----------------------------------------------------------
' =============== START BACKUP OF REGISTRY KEYS USED FOR ===============
' Original Command
' strCommand = "regedit /e <FilePath> <RegKey>"
' Local Machine ......
strCommand = "regedit /e " & strHostName & "-" & strDate & "-" & _
strTime & "-BackupLM-Notepad++.reg " & _
"""HKEY_LOCAL_MACHINE\SOFTWARE\Classes" & _
"\CLSID\{00F3C2EC-A6EE-11DE-A03A-EF8F55D89593}"""
Set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run(strCommand, 0, TRUE)
If intRC <> 0 then
WScript.Echo "Error returned from exporting Registry: " & intRC
Else
WScript.Echo "No errors returned from exporting the Registry file"
End If
' =============== END BACKUP OF REGISTRY KEYS USED FOR ===============
' -----------------------------------------------------------
' =============== START NEW OPEN * SHELL COMMAND ===============
' Name of Registry Entry Key\Path
strKeyPath = "*\shell\Edit With Notepad++\command"
objReg.CreateKey HKEY_CLASSES_ROOT,strKeyPath
' Name of Registry Entry String
strValueName = ""
strValue = "C:\progra~1\notepad++\notepad++.exe %1"
objReg.SetStringValue HKEY_CLASSES_ROOT,strKeyPath,NULL,strValue
' =============== START NEW OPEN DIRECTORY SHELL COMMAND ===============
' Name of Registry Entry Key\Path
strKeyPath = "Directory\shell\Edit With Notepad++\command"
objReg.CreateKey HKEY_CLASSES_ROOT,strKeyPath
' Name of Registry Entry String
strValueName = ""
strValue = "C:\progra~1\notepad++\notepad++.exe %1"
objReg.SetStringValue HKEY_CLASSES_ROOT,strKeyPath,NULL,strValue
' -----------------------------------------------------------
strKeyPath = "*\shellex\ContextMenuHandlers\ANotepad++"
objRegistry.DeleteKey HKEY_CLASSES_ROOT,strKeyPath
strKeyPath = "SOFTWARE\Classes\CLSID\{00F3C2EC-A6EE-11DE-A03A-EF8F55D89593}\Settings"
objRegistry.DeleteKey HKEY_LOCAL_MACHINE,strKeyPath
' Ending Message
MsgBox"Notepad++ Right-Click Settings" & VbCrLf & _
"Have Been Created", ,"Click OK To Close Window"
' Cleans up Variables From Memory
Set objFSO = Nothing
Set objWrite2File = Nothing
Set objShell = Nothing
Set objReg = Nothing
Set objRegistry = Nothing
Set objWshShell = Nothing
Set strDate = Nothing
Set strTime = Nothing
Set strTime2 = Nothing
Set strFileName = Nothing
Set strOpenFile = Nothing
Set strComputer = Nothing
Set strCommand = Nothing
Set strHostName = Nothing
Set strUserName = Nothing
Set intRC = Nothing
Set strKeyPath = Nothing
Set strValueName = Nothing
Set strValue = Nothing
End If