Problem Description
When using the {path} parameter to create custom shortcuts, there is a known limitation/bug regarding the Windows 11 Navigation Pane (Left Sidebar).
If a user right-clicks a folder inside the Left Navigation Pane, the application passes a path that Windows interprets dynamically as the container or parent folder. As a result, the shortcut (.lnk) is created a level above (in the parent directory) instead of inside the current folder the user is interacting with.
Additionally, trying to resolve this strictly via VBScript text manipulation paths (like fso.GetParentFolderName or mathematical cleanups) fails because Windows internally hooks the focus onto the container directory.
Solution
The fix requires changing the logic from basic path manipulation to an Interface Focus Detection approach using the native Shell.Application engine. By analyzing the graphic window active element (.Document.FocusedItem), the script can mathematically deduce if the click came from the Left Navigation Pane (when the active focused item on the right pane does not match the triggered path).
Once detected, the script overrides the default behavior and forces the shortcut's destinationFolder strictly inside the target path. It also implements an automatic "Rescue to Desktop" rule if Windows UAC blocks file creation on root units like C:\.
Recommended Configuration in Custom Context Menu App:
- Casillas activas (Type): Check ONLY
Directory (leave Background, Desktop, and Drive unchecked).
- Match Expression (RegEx):
^(?!.*\.lnk$).*$
- Exe:
wscript.exe
- Param:
"C:\Path\To\Your\Script\crear_acceso.vbs" "{path}"
Universal VBScript Code (crear_acceso.vbs):
On Error Resume Next
Set args = WScript.Arguments
If args.Count = 0 Then WScript.Quit
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
desktopPath = shell.SpecialFolders("Desktop") & "\"
path = fso.GetAbsolutePathName(args(0))
If path = "" Then WScript.Quit
If Right(path, 1) = "\" And Len(path) > 3 Then
path = Left(path, Len(path) - 1)
End If
If LCase(fso.GetExtensionName(path)) = "lnk" Then WScript.Quit
If Len(path) <= 3 Then
driveLetter = Left(path, 1)
Set lnk = shell.CreateShortcut(desktopPath & "Disco " & driveLetter & ".lnk")
lnk.TargetPath = path & "\"
lnk.Save
WScript.Quit
End If
vieneDeIzquierda = False
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
For i = 0 To objWindows.Count - 1
If InStr(LCase(objWindows.Item(i).FullName), "explorer.exe") > 0 Then
Set focusedItem = objWindows.Item(i).Document.FocusedItem
If Not focusedItem Is Nothing Then
If LCase(focusedItem.Path) <> LCase(path) Then
vieneDeIzquierda = True
End If
Else
vieneDeIzquierda = True
End If
Exit For
End If
Next
If fso.FolderExists(path) Then
folderName = fso.GetFileName(path)
If folderName = "" Then folderName = "Acceso_Carpeta"
If LCase(folderName) = "desktop" Then
destinationFolder = desktopPath
fileNameLnk = "Acceso a Escritorio"
ElseIf vieneDeIzquierda Then
destinationFolder = path & "\"
fileNameLnk = folderName
Else
parentFolder = fso.GetParentFolderName(path)
If parentFolder <> "" Then
If Right(parentFolder, 1) <> "\" Then parentFolder = parentFolder & "\"
End If
destinationFolder = parentFolder
fileNameLnk = folderName
End If
Set lnk = shell.CreateShortcut(destinationFolder & fileNameLnk & ".lnk")
lnk.TargetPath = path
lnk.Save
ElseIf fso.FileExists(path) Then
parentFolder = fso.GetParentFolderName(path)
fileName = fso.GetBaseName(path)
If parentFolder <> "" Then
If Right(parentFolder, 1) <> "\" Then parentFolder = parentFolder & "\"
Set lnk = shell.CreateShortcut(parentFolder & fileName & ".lnk")
lnk.TargetPath = path
lnk.Save
End If
End If
Problem Description
When using the
{path}parameter to create custom shortcuts, there is a known limitation/bug regarding the Windows 11 Navigation Pane (Left Sidebar).If a user right-clicks a folder inside the Left Navigation Pane, the application passes a path that Windows interprets dynamically as the container or parent folder. As a result, the shortcut (.lnk) is created a level above (in the parent directory) instead of inside the current folder the user is interacting with.
Additionally, trying to resolve this strictly via VBScript text manipulation paths (like
fso.GetParentFolderNameor mathematical cleanups) fails because Windows internally hooks the focus onto the container directory.Solution
The fix requires changing the logic from basic path manipulation to an Interface Focus Detection approach using the native
Shell.Applicationengine. By analyzing the graphic window active element (.Document.FocusedItem), the script can mathematically deduce if the click came from the Left Navigation Pane (when the active focused item on the right pane does not match the triggered path).Once detected, the script overrides the default behavior and forces the shortcut's
destinationFolderstrictly inside the target path. It also implements an automatic "Rescue to Desktop" rule if Windows UAC blocks file creation on root units likeC:\.Recommended Configuration in Custom Context Menu App:
Directory(leave Background, Desktop, and Drive unchecked).^(?!.*\.lnk$).*$wscript.exe"C:\Path\To\Your\Script\crear_acceso.vbs" "{path}"Universal VBScript Code (
crear_acceso.vbs):