Fla$her wrote: 2024-11-05, 21:53 UTC
tuska wrote: 2024-11-05, 21:29 UTC
For me, this topic is finally closed.
Now imagine that everyone will answer you exactly the same way, without waiting for an indication of mistakes,
when you try to help others...
I tried to sign off as a tester for your topic, unfortunately once again without success.

Reasons:
- The OP found a solution for himself and showed no further interest in your script (and not the NirSoft solution either).
- I have been using the solution from Horst.Epp (NirSoft utilities) for years and therefore don't really need the .vbs script.
So no offense intended...
Where are we now?
- Thanks to your further targeted advice, the problems mentioned here (spaces, *.lnk files) no longer exist.
Regarding the .lnk to OneDrive, I had two links in which the wrong destination was set for one of the .lnks,
i.e. this problem has also been solved.
I could have saved a lot of time if I had the
correct ButtonCODE and em_CODE at the beginning
- I can do just as much with your script as with the NirSoft solution:
%COMMANDER_PATH%\Tools\NirCmd\nircmd.exe exec show %COMMANDER_EXE% /O /S /A /L="~$clipboard$
However, a professional user can probably do more with the .vb script.
Spoiler: Original title...
TCNavigatorByPathFromClipboard.vbs (save with ANSI/UTF-16, create a em_command/button with the script path and specified param's):
Code: Select all
'——————————————————————————————— VBS ———————————————————————————————
' Assignment: Smart navigating to an object in the active panel by
' file/folder name, registry key, or GUID specified in the clipboard
' Parameters: "<name of the registry plugin in wfx-list>" "%P%Z"
'———————————————————————————————— Author: Flasher (11.08.2013) © ———
Option Explicit: Dim oWSH, oFSO, R, A, C, oREx, F
Const Title = " Navigating a path in the TC panel"
If WSH.Arguments.Count <> 2 Then MsgBox "Specify two parameters!", 262192, Title: WSH.Quit
Set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
R = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1407"
A = oWSH.RegRead(R): If A > 0 Or Err.Number <> 0 Then oWSH.RegWrite R, 0, "REG_DWORD"
C = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
If A > 0 Then oWSH.RegWrite R, A, "REG_DWORD"
On Error Goto 0: If Len(C) = 0 Then Quit 0
Set oREx = New RegExp
With oREx
.IgnoreCase = 1
.Pattern = "(H[CK]|(::)?\{|%|[A-Z]:)[^\r\n""]+[^\s\\""]"
If .Test(C) Then
C = .Execute(C)(0)
Else .Pattern = " *[^\s/|:\\<*?>""][^\r\n\t|:<*?>""]*"
If .Test(C) Then C = RTrim(.Execute(C)(0)) Else Quit 1
End If : .Pattern = "^(::)?\{"
End With
C = Replace(Replace(Replace(C, " \ ", "\"), " / ", "/"), """", "")
If InStr(1, "|HK|HC|", "|" & Left(C, 2) & "|", 1) Then
If Right(C, 1) = "]" Then C = Left(C, Len(C) - 1)
R = InStr(C, ":") : If R = 4 Or R = 5 Then _
C = Left(C, R - 1) & Mid(C, R + 1)
C = oFSO.BuildPath(Replace(C, "/", "\"), "\")
Select Case UCase(Left(C, InStr(C, "\") - 1))
Case "HKCU" C = "HKEY_CURRENT_USER" & Mid(C, 5)
Case "HKLM" C = "HKEY_LOCAL_MACHINE" & Mid(C, 5)
Case "HKCR" C = "HKEY_CLASSES_ROOT" & Mid(C, 5)
Case "HKCC" C = "HKEY_CURRENT_CONFIG" & Mid(C, 5)
Case "HKU" C = "HKEY_USERS" & Mid(C, 4)
End Select : On Error Resume Next : oWSH.RegRead(C)
Do Until Err.Number = 0
On Error Goto 0
If InStr(C, "\") = Len(C) Then Exit Do
C = oFSO.GetParentFolderName(C) & "\"
On Error Resume Next : oWSH.RegRead(C)
Loop : C = "\\\" & WSH.Arguments(0) & "\" & C
ElseIf Not oREx.Test(C) Then
oREx.Pattern = "^(%|[A-Z]:)?[^:?*<|>]+"
If oREx.Test(C) Then C = oWSH.ExpandEnvironmentStrings(oREx.Execute(C)(0)) Else Quit 1
oREx.Pattern = ".+/.+\\.+|.+\\.+/.+" : If oREx.Test(C) Then _
oREx.Pattern = "(.+)[\\/][^\\/]+[\\/]?$" :_
If oREx.Test(C) Then Set C = oREx.Execute(C)(0) :_
If oFSO.FolderExists("\\?\" & C) + oFSO.FileExists("\\?\" & C) = 0 Then C = C.Submatches(0)
If Mid(C, 2, 1) = ":" Then
F = Left(C, Len(C) - 1)
If oFSO.FileExists("\\?\" & C) + oFSO.FolderExists("\\?\" & C) = 0 Then _
If oFSO.FileExists("\\?\" & F) + oFSO.FolderExists("\\?\" & F) < 0 Then C = F
Else
C = WSH.Arguments(1) & C
If oFSO.FileExists("\\?\" & C) + oFSO.FolderExists("\\?\" & C) = 0 Then
For R = 3 To UBound(Split(Replace(C, "/", "\"), "\"))
If oFSO.FolderExists("\\?\" & C) Then R = 0 : Exit For Else C = oFSO.GetParentFolderName(C)
Next : If R Then Quit 1
End If
End If
If StrComp(oFSO.BuildPath(C, "\"), WSH.Arguments(1), 1) = 0 Then Quit 0
If oFSO.FolderExists("\\?\" & C) + oFSO.FileExists("\\?\" & C) = 0 Then Quit 1 Else C = C & "\:"
Else On Error Resume Next
If Left(C, 1) = "{" Then C = "::" & C
If CreateObject("Shell.Application").NameSpace("shell:" & C) Is Nothing Then Quit 1
If Err Then Quit 1
End If
If StrComp(oFSO.BuildPath(C, "\"), WSH.Arguments(1), 1) = 0 Then Quit 0
oWSH.Sendkeys "^{F10}": oWSH.Run """%COMMANDER_EXE%"" /A /O /S """ & C & """": Quit 0
Sub Quit(T)
If T Then MsgBox "The contents of the clipboard are not equivalent" & vbCr &_
"to an existing path in the system or registry !", 262192, Space(24) & Title
Set oFSO = Nothing: Set oWSH = Nothing: Set oREx = Nothing: WSH.Quit
End Sub
Work algorithm:
- If both slashes are present in the path to the missing directory/file, the parent folder will become the object to be navigated.
- Registry keys can be written as abbreviations (HKCU, HKCR, HKLM, HKCC, HCU) in any register and have ':' at the end.
- If a parameter or a non-existent registry key is specified, it will jump to an existing hive in the path chain.
- The separator in the path chain can be a forward or back slash, including those with extra spaces on both sides.
- Long paths (more than 259 characters), relative paths, and paths with environment variables are supported.
- Extra trailing spaces, tabs, line breaks, quotation marks, square brackets can be indicated.
- In the relative path chain, all constituent components are also checked for presence.
- Forbidden characters at the end of file and directory paths are trimmed.
- A virtual directory can be opened by {GUID} or ::{GUID}.
Code: Select all
TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
Registry "%P%Z"
wcmicon2.dll,4
Path\to\TCNavigatorByPathFromClipboard.vbs Parameter: Registry "%P%Z"|Navigate to the path, registry key, or GUID specified on the clipboard|https://www.ghisler.ch/board/viewtopic.php?p=463229#p463229|How to import clipping items into the path editing bar
-1
Code: Select all
TOTALCMD#BAR#DATA
em_TCNavigatorByPathFromClipboard
wciconex.dll
em_TCNavigatorByPathFromClipboard || wfx_registry_5.2|Path\to\TCNavigatorByPathFromClipboard.vbs Parameter: Registry "%P%Z"|https://www.ghisler.ch/board/viewtopic.php?p=463015#p463015|How to import clipping items into the path editing bar
0
-1
Code: Select all
[em_TCNavigatorByPathFromClipboard]
button=
cmd=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs
param="Registry "%P%Z""
menu=%COMMANDER_PATH%\Tools\Skripts\TCNavigatorByPathFromClipboard.vbs|Parameters: "Registry "%P%Z""|https://www.ghisler.ch/board/viewtopic.php?p=463015#p463015
EDIT:
Added
Work algorithm.
See: TCNavigatorByPathFromClipboard.vbs - author: Fla$her
Windows 11 Pro (x64)
Version 23H2 (OS Build 22631.4391) |
TC 11.50b4 x64/x86
NirSoft utilities 2.8.7.232 - 23.4.2024 | Download links at the very bottom...
Registry 5.2 |
CoRegistry 1.1.0.0