Code:
' Created by Sergey Tkachenko
' (c) http://winaero.com/
Dim objHTA
Dim cClipBoard
Dim WshShell
set objHTA=createobject("htmlfile")
cClipBoard=objHTA.parentwindow.clipboarddata.getdata("text")
Set WshShell = WScript.CreateObject("WScript.Shell")
[B]if findstring([cClipBoard], "HKCR")>=0 then
Call Replace([cClipBoard], "HKCR", "HKEY_CLASSES_ROOT")
elseif findstring([cClipBoard], "HKCU")>=0 then
Call Replace([cClipBoard], "HKCU", "HKEY_CURRENT_USER")
elseif findstring([cClipBoard], "HKLM")>=0 then
Call Replace([cClipBoard], "HKLM", "HKEY_LOCAL_MACHINE")
elseif findstring([cClipBoard], "HKU")>=0 then
Call Replace([cClipBoard], "HKU", "HKEY_USERS")
else
[cClipBoard]
End If[/B]
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey", cClipBoard, "REG_SZ"
WshShell.Run "regedit.exe -m"
Set objHTA = nothing
Set WshShell = nothing
Set cClipBoard = nothing
Obviously I'm trying to add conditions that will handle the root key abbriviations for HKCR, HKCU, etc.
Adding "Call" to the Replace function was the only way to get rid of the initial error "cannot use parentheses when calling a sub"
Now I can't handle the "Type Mismatch" error on "findstring".
The only thing I can think of is that it's not recognizing [cClipBoard]. I have no idea what object to use to describe and edit then.
Maybe windows default clipboard contents cannot be edited and I have to edit it once written in LastKey registry?
Note: If I use i.e. "HKCR\WIA.DeviceManager\CLSID" on the clipboard, the registry opens but not to any KEY, and checking WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey" (Ironically the abbriviation is used here) THIS is the data in the LastKey = "HKCR\WIA.DeviceManager\CLSID", which of course needs to rather be "HKEY_CLASSES_ROOT\WIA.DeviceManager\CLSID"
Any ideas?
Also posted here.