Is there or could there be support opening relative path shortcuts?
Moderators: Hacker, Stefan2, white
Is there or could there be support opening relative path shortcuts?
The parameter format of the relative path shortcut is "Target Args", e.g. "C:\Windows\explorer.exe ..\..\aaa\bbb\"
or "C:\Windows\explorer.exe ..\..\aaa\bbb\11.txt"
Can totalcmd support opening relative path shortcuts?
If it is a relative path shortcut to a file, it will be treated like a file by internal associations as a priority.
If it is a relative path shortcut to a directory, it will be treated like a directory and opened in the current panel via totolcmd.
That started over there >> https://ghisler.ch/board/viewtopic.php?t=78413
or "C:\Windows\explorer.exe ..\..\aaa\bbb\11.txt"
Can totalcmd support opening relative path shortcuts?
If it is a relative path shortcut to a file, it will be treated like a file by internal associations as a priority.
If it is a relative path shortcut to a directory, it will be treated like a directory and opened in the current panel via totolcmd.
That started over there >> https://ghisler.ch/board/viewtopic.php?t=78413
- ghisler(Author)
- Site Admin
- Posts: 44621
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Is there or could there be support opening relative path shortcuts?
Do you mean .lnk files containing relative paths? So far I couldn't create these, how did you achieve that?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Is there or could there be support opening relative path shortcuts?
2ghisler(Author)
The wording "relative path shortcuts" is confusing. They are not relative path shortcuts, but normal shortcuts to explorer with a parameter containing a relative path.
See here (replace http with https in the link to the Relative tool ).
The wording "relative path shortcuts" is confusing. They are not relative path shortcuts, but normal shortcuts to explorer with a parameter containing a relative path.
See here (replace http with https in the link to the Relative tool ).
Re: Is there or could there be support opening relative path shortcuts?
There is nothing complicated here. Example with execution .vbs from TC:ghisler(Author) wrote: ↑2023-02-09, 11:21 UTCSo far I couldn't create these, how did you achieve that?
Code: Select all
With CreateObject("WScript.Shell")
NF = .Environment("PROCESS")("COMMANDER_PATH") & "\Sub1\Sub2"
CreateObject("Shell.Application").NameSpace(Left(NF, 2)).NewFolder Mid(NF, 4)
With .CreateShortcut(NF & "\TOTALCMD.CHM.lnk")
.TargetPath = "%WINDIR%\explorer.exe"
.Arguments = "..\..\TOTALCMD.CHM"
.IconLocation = "%WINDIR%\hh.exe"
.Save
End With
.Exec "%COMMANDER_EXE% /A /S /O0 """ & NF & "\TOTALCMD.CHM.lnk"""
End With
Code: Select all
%WinDir%\System32\rundll32.exe url.dll, OpenURL
%WinDir%\System32\rundll32.exe url.dll, FileProtocolHandler
%WinDir%\System32\rundll32.exe shell32.dll,ShellExec_RunDLL
Re: Is there or could there be support opening relative path shortcuts?
Thank you for your explanation, I created it using ahk.Fla$her wrote: ↑2023-02-09, 13:14 UTCThere is nothing complicated here. Example with execution .vbs from TC:ghisler(Author) wrote: ↑2023-02-09, 11:21 UTCSo far I couldn't create these, how did you achieve that?There's just one catch. There won't necessarily be explorer.exe, there may be other combinations. For example:Code: Select all
With CreateObject("WScript.Shell") NF = .Environment("PROCESS")("COMMANDER_PATH") & "\Sub1\Sub2" CreateObject("Shell.Application").NameSpace(Left(NF, 2)).NewFolder Mid(NF, 4) With .CreateShortcut(NF & "\TOTALCMD.CHM.lnk") .TargetPath = "%WINDIR%\explorer.exe" .Arguments = "..\..\TOTALCMD.CHM" .IconLocation = "%WINDIR%\hh.exe" .Save End With .Exec "%COMMANDER_EXE% /A /S /O0 """ & NF & "\TOTALCMD.CHM.lnk""" End With
Code: Select all
%WinDir%\System32\rundll32.exe url.dll, OpenURL %WinDir%\System32\rundll32.exe url.dll, FileProtocolHandler %WinDir%\System32\rundll32.exe shell32.dll,ShellExec_RunDLL
FileCreateShortcut, %SystemRoot%\explorer.exe, LinkName.lnk,,%relativePath% , ,imageres.dll ,, 279
Re: Is there or could there be support opening relative path shortcuts?
It is possible that the name is wrong. In the Chinese environment, we all call it this way.white wrote: ↑2023-02-09, 12:15 UTC 2ghisler(Author)
The wording "relative path shortcuts" is confusing. They are not relative path shortcuts, but normal shortcuts to explorer with a parameter containing a relative path.
See here (replace http with https in the link to the Relative tool ).
But I saw Microsoft's official reply is also called so.
https://answers.microsoft.com/en-us/windows/forum/all/how-to-create-a-shortcut-with-relative-path/3e1b0ede-1e18-4ecd-937b-66756d3409d3
- ghisler(Author)
- Site Admin
- Posts: 44621
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Is there or could there be support opening relative path shortcuts?
I have tried your vbscript - links to files already work, but links to folders open an Explorer window instead of being opened internally. If you want me to support these links, you need to provide a way to detect them.
So far you have provided the following list:
Of course it would also have to check without environment variables, so better expand them before comparing. a varying amount of spaces may also further complicate it. Any other things to consider?
So far you have provided the following list:
Code: Select all
%WINDIR%\explorer.exe"
%WinDir%\System32\rundll32.exe url.dll, OpenURL
%WinDir%\System32\rundll32.exe url.dll, FileProtocolHandler
%WinDir%\System32\rundll32.exe shell32.dll,ShellExec_RunDLL
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Is there or could there be support opening relative path shortcuts?
That a support employee uses this terminology doesn't mean it is an official statement by Microsoft.yahuu wrote: ↑2023-02-10, 08:37 UTC But I saw Microsoft's official reply is also called so.
https://answers.microsoft.com/en-us/windows/forum/all/how-to-create-a-shortcut-with-relative-path/3e1b0ede-1e18-4ecd-937b-66756d3409d3
I believe there is also a variant with cmd:ghisler(Author) wrote: ↑2023-02-13, 11:07 UTC Of course it would also have to check without environment variables, so better expand them before comparing. a varying amount of spaces may also further complicate it. Any other things to consider?
%comspec% /c start <relative path to file or folder>
Furthermore, shouldn't it be optional? People may have created these shortcuts to launch Explorer from Total Commander..
Re: Is there or could there be support opening relative path shortcuts?
This is the essence of the request, so that the opening takes place in the TC file panel.ghisler(Author) wrote: ↑2023-02-13, 11:07 UTCbut links to folders open an Explorer window instead of being opened internally.
I also did a test version for the folder, if someone suddenly needs it.
Code: Select all
With CreateObject("WScript.Shell")
NF = .Environment("PROCESS")("COMMANDER_PATH") & "\Sub1\Sub2\"
CreateObject("Shell.Application").NameSpace(Left(NF, 2)).NewFolder Mid(NF, 4)
With .CreateShortcut(NF & "Language.lnk")
.TargetPath = "%WinDir%\System32\rundll32.exe"
.Arguments = "url.dll, OpenURL ..\..\Language\"
.IconLocation = "shell32.dll,2"
.Save
End With
.Exec "%COMMANDER_EXE% /P /S /O0 """ & NF & "Language.lnk"""
End With
It is better to solve this by using regular expressions. For example: ^%ComSpec% *(/q *)?/c *start *("")? *(..?\)*([^*|<>?:"]+)$ghisler(Author) wrote: ↑2023-02-13, 11:07 UTCa varying amount of spaces may also further complicate it.
- ghisler(Author)
- Site Admin
- Posts: 44621
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Is there or could there be support opening relative path shortcuts?
This is a valid request. Maybe I should only support some of the variants?Furthermore, shouldn't it be optional? People may have created these shortcuts to launch Explorer from Total Commander..
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Is there or could there be support opening relative path shortcuts?
Previous versions of TCIMG have the function of creating relative link shortcuts, but only support directly related directories, such as "D:\01\011\0111" and "D:\01\011\0111\01111\" relative pathsghisler(Author) wrote: ↑2023-02-13, 11:07 UTC I have tried your vbscript - links to files already work, but links to folders open an Explorer window instead of being opened internally. If you want me to support these links, you need to provide a way to detect them.
So far you have provided the following list:Of course it would also have to check without environment variables, so better expand them before comparing. a varying amount of spaces may also further complicate it. Any other things to consider?Code: Select all
%WINDIR%\explorer.exe" %WinDir%\System32\rundll32.exe url.dll, OpenURL %WinDir%\System32\rundll32.exe url.dll, FileProtocolHandler %WinDir%\System32\rundll32.exe shell32.dll,ShellExec_RunDLL
But "D:\01\011\0111" and "D:\01\021\0222" are not supported.
After I submitted the bug, the author made a fix
TCIMG also supports directory shortcuts to be opened with the current tab in TC, but relative paths are not supported.
The functionality I expect is:
1. When opening a file, use TC internal association
2. When opening the directory, use the tab opposite the TC, or provide parameters to configure local or opposite. The reason is that after pressing Backspace, instead of returning to the original directory, it returns to the upper level of the directory where the shortcut is located, so it is best to open it on the opposite side.
The following vbs command can create a relative path shortcut:
Code: Select all
Function GetRelativePathA(sPath, sFolder)
GetRelativePathA = sPath
If sPath = sFolder Then Exit Function
If Right(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
If sPath = sFolder Then Exit Function
aPath = Split(sPath, "\") : aFolder = Split(sFolder, "\")
If aPath(0) <> aFolder(0) Then Exit Function
nP = UBound(aPath) : nF = UBound(aFolder)
For i = 0 To nP
If i > nF Or aPath(i) <> aFolder(i) Then Exit For
Next
For j = i To nF - 1
relativePath = relativePath & "..\"
Next
For j = i To nP- 1
relativePath = relativePath & aPath(j) & "\"
Next
GetRelativePathA = relativePath & aPath(nP)
End Function
Re: Is there or could there be support opening relative path shortcuts?
Currently I'm using ahk to achieve:
According to the path where the shortcut file is located, after converting the parameters of the shortcut into an absolute path, determine its properties
1. If it is a file, open it with F4Menu
2. If it is a directory, use the tab opposite to TC to open it
According to the path where the shortcut file is located, after converting the parameters of the shortcut into an absolute path, determine its properties
1. If it is a file, open it with F4Menu
2. If it is a directory, use the tab opposite to TC to open it
Last edited by yahuu on 2023-02-22, 04:13 UTC, edited 1 time in total.
Re: Is there or could there be support opening relative path shortcuts?
%comspec% works, but I tried using totalcmd.exe with command line arguments and it still doesn't work. It should be that totalcmd.exe does not know the relative path relative to whom.white wrote: ↑2023-02-13, 11:28 UTCThat a support employee uses this terminology doesn't mean it is an official statement by Microsoft.yahuu wrote: ↑2023-02-10, 08:37 UTC But I saw Microsoft's official reply is also called so.
https://answers.microsoft.com/en-us/windows/forum/all/how-to-create-a-shortcut-with-relative-path/3e1b0ede-1e18-4ecd-937b-66756d3409d3
I believe there is also a variant with cmd:ghisler(Author) wrote: ↑2023-02-13, 11:07 UTC Of course it would also have to check without environment variables, so better expand them before comparing. a varying amount of spaces may also further complicate it. Any other things to consider?
%comspec% /c start <relative path to file or folder>
Furthermore, shouldn't it be optional? People may have created these shortcuts to launch Explorer from Total Commander..