OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

English support forum

Moderators: Stefan2, Hacker, petermad

fc62
Junior Member
Junior Member
Posts: 64
Joined: 2007-02-06, 16:30 UTC

Re: OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

Post by *fc62 »

beb
I have read and carefully noted all the suggestions and the changes to the script that you proposed, as well as the modification to Ctrl+Q that ghisler (Author) introduced in RC3, for which I would like to thank you very much in advance. I can’t wait to test everything as soon as possible, but for the past 10 days I’ve been on a business trip between India and China, and I only have my company laptop with me. On this machine I can run only limited tests because it is protected by a very restrictive firewall and antivirus, which significantly limit my freedom of action.I’m really looking forward to returning in about 10 days so I can test everything properly and provide you with my feedback.
Thanks again
User avatar
beb
Power Member
Power Member
Posts: 762
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

Post by *beb »

2fc62
I appreciate your reply. Have a good trip!
#278521 User License
Total Commander [always the latest version, including beta] x86/x64 on Win10 x64/Windows 11/Android 17
fc62
Junior Member
Junior Member
Posts: 64
Joined: 2007-02-06, 16:30 UTC

Re: OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

Post by *fc62 »

2Beb
I’m back from my long business trip and I have tested your script.
Actually, I’m getting an error.

I performed several tests, and below is an example of the error I get with the image file "Test04.png".

If I run the command from the following test directory, it works perfectly:
d:\OneDrive\00-Sync\Total\Test04.png

The text displayed in the PowerShell window is as follows:
current working path
D:\OneDrive\00-Sync\Total

%WL list file
CMD7BE.tmp

%P source path
d:\OneDrive\00-Sync\Total\
%T target path
\\localhost\OneDrive\00-Sync\Total\lnk\

processing 1 items from %WL list file...
URL=d:\OneDrive\00-Sync\Total\Test04.png

1 items processed for 00:00.531
by makeURLfiles.ps1


The following information is shown in the properties of the URL shortcut:
file:///d:/OneDrive/00-Sync/Total/Test04.png

_______________________________________________________________________________________

If I run the command from the following test directory, I get an error:
\\localhost\OneDrive\00-Sync\Total\Test04.png

The text displayed in the PowerShell window is as follows:
Unable to convert the value "Microsoft.PowerShell.Core\FileSystem::\\localhost\OneDrive\00-Sync\Total" to the type
"System.IO.DirectoryInfo". Error: "The specified path format is not supported."
In C:\totalcmd\Plugins\PowerShell\makeURLfiles.ps1:2 car:1
+ $path = [IO.DirectoryInfo]$pwd.path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastConstructorException


%WL list file
CMD198E.tmp

%P source path
\\localhost\OneDrive\00-Sync\Total\
%T target path
\\localhost\OneDrive\00-Sync\Total\lnk\

processing 1 items from %WL list file...
URL=\\localhost\OneDrive\00-Sync\Total\Test04.png

1 items processed for 00:00.788
by makeURLfiles.ps1


The following information is shown in the properties of the URL shortcut:
file:///d:/OneDrive/00-Sync/Total/Test04.png

In the shortcut properties, I manually modified the URL text as follows:
file://localhost/OneDrive/00-Sync/Total/Test04.png
After doing so, it works correctly.

+++++++++++++++++++++++++++++++++++++++++++++++++++++

I also tested the new feature that ghisler (Author) has introduced to follow .url files in Quick View (Ctrl+Q), and it seems to work very well in all cases, including from the \\localhost\ directory.
The only issue I have identified is with Microsoft Office files such as .docx or .xlsx. Instead of displaying a preview, Total Commander opens the files in their respective applications.
I’m not sure whether I need to change a specific setting to alter this behavior.
User avatar
beb
Power Member
Power Member
Posts: 762
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

Post by *beb »

2fc62
  1. Try a modified version of the makeURLfiles.ps1 script:

    Code: Select all

    $time = [diagnostics.stopwatch]::StartNew()
    
    if (-not $args){
        Write-Warning 'no parameters have been passed, exiting...'
        sleep -seconds 3
        exit
    }
    
    $path = [IO.DirectoryInfo]$pwd.ProviderPath
    if ($path){
    'current working path'|Write-Host -f DarkGray
        $path.FullName
    }
    ''
    if ($args){
    '%WL list file'|Write-Host -f DarkGray
        $list = [IO.FileInfo]$args[0]
        $list.Name
    ''
    '%P source path'|Write-Host -f DarkCyan
        $cleanSource = $args[1] -replace '^.*::', ''
        $source = [IO.DirectoryInfo]$cleanSource
        $source.FullName
    
    '%T target path'|Write-Host -f DarkCyan
        $cleanTarget = $args[2] -replace '^.*::', ''
        $target = [IO.DirectoryInfo]$cleanTarget
        $target.FullName
    }
    ''
    if ($args -and $list.length -le 2){
        Write-Warning '%WL list file is empty, exiting...'
        sleep -seconds 3
        exit
    }
    
    # read input list file and collect items
    $items = @([IO.File]::ReadLines($list.FullName)|foreach{
       if(-not [string]::IsNullOrWhiteSpace($_)){
           $_
       }
    })
    
    if (-not $items.count){
        Write-Warning '%WL list file contains no items, exiting...'
        sleep -seconds 3
        exit
    }
    
    # OneDrive and localhost literal definitions
    $OneDrive  = 'd:\OneDrive'
    $localhost = '\\localhost\OneDrive'
    
    # process items from %WL list file
    'processing {0} items from %WL list file...' -f $items.count|Write-Host -f Yellow
    
    foreach ($item in $items){
    
    $cleanItem = $item -replace '^.*::', ''
    
    # URL address: if item is within $OneDrive change it to $localhost
    if($cleanItem -like "$OneDrive\*"){
        $URL = $cleanItem.Replace($OneDrive,$localhost)
    }
    else {
        $URL = $cleanItem # otherwise leave item intact
    }
    # display current URL
    'URL={0}' -f $URL
    
    # uncomment the following line if you need URI-formatted $URL
    #$URL = ([URI]$URL).AbsoluteUri
    
    # URL file contents
        $text=[Text.StringBuilder]::new()
        [void]$text.AppendLine('[InternetShortcut]')
        [void]$text.AppendLine("URL=$URL")
    # URL file destination path and naming
        $base = Split-Path $cleanItem -leaf
        $URLfile = [IO.Path]::combine($target.FullName,"$base.url")
    # avoid naming collisions
    $counter = 1
    while ([IO.File]::Exists($URLfile)) {
        $URLfile = [IO.Path]::combine($target.FullName,"$base($counter).url")
        $counter++
    }
    # write URL file
    [IO.File]::WriteAllText($URLfile,$text.ToString(),[Text.Encoding]::Unicode)
    }
    ''
    # finalize
    $time.Stop()
    '{0} items processed for {1:mm\:ss\.fff}' -f $items.count,
    $time.Elapsed|Write-Host -f DarkCyan
    'by {0}' -f $MyInvocation.MyCommand.Name
    sleep -seconds 7
  2. Apparently, you need a proper plugin to display .docx and .xlsx-like files' contents under Ctrl+Q.
    For me, this one works well for this task:
    viewtopic.php?t=87678
    https://github.com/michal-ruzicka/TCOfficeView
  3. fc62 wrote: 2026-07-12, 18:13 UTC If I run the command from the following test directory, it works perfectly:
    d:\OneDrive\00-Sync\Total\Test04.png
    ...
    The following information is shown in the properties of the URL shortcut:
    file:///d:/OneDrive/00-Sync/Total/Test04.png
    ...
    If I run the command from the following test directory, I get an error:
    \\localhost\OneDrive\00-Sync\Total\Test04.png
    ...
    The following information is shown in the properties of the URL shortcut:
    file:///d:/OneDrive/00-Sync/Total/Test04.png

    In the shortcut properties, I manually modified the URL text as follows:
    file://localhost/OneDrive/00-Sync/Total/Test04.png
    After doing so, it works correctly.
    This provides little to no insight into what was initially wrong with the URL value in the URL file got when running the command/script within //localhost, and what was actually changed upon modifying its properties manually via Explorer.
    What might have been useful is to compare the "before" and "after" literal URL= values of the URL file, which is effectively a text file and can be opened in a text editor.
    Anyway, with the modified version of the script (which I changed to process the network shares paths natively), the command should now likely work regardless.
    And if it does work, there would be no further need or interest to investigate this point (at least for me).
    However, if the resulting .URL shortcut itself won't work, I will need the following info to make a fix:
    shortcut_that_does_not_work.URL

    Code: Select all

    [InternetShortcut]
    URL=literal_path_that_does_not_work
    manually_made_shortcut_that_works.URL

    Code: Select all

    [InternetShortcut]
    URL=manually_made_literal_path_that_works
#278521 User License
Total Commander [always the latest version, including beta] x86/x64 on Win10 x64/Windows 11/Android 17
User avatar
beb
Power Member
Power Member
Posts: 762
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: OneDrive no longer syncs .lnk files (since April) – quick way to create .URL links in Total Commander?

Post by *beb »

I have replicated "d:\OneDrive\00-Sync\Total\Test04.png" path on my machine and made "d:\OneDrive" accessible as "\\localhost\OneDrive" via Advanced Sharing...
I also made a test version of the script, which produces all possible .URL shortcuts at once:
makeURLfiles_AIO.ps1

Code: Select all

$time = [diagnostics.stopwatch]::StartNew()

if (-not $args){
    Write-Warning 'no parameters have been passed, exiting...'
    sleep -seconds 3
    exit
}

$path = [IO.DirectoryInfo]$pwd.ProviderPath
if ($path){
'current working path'|Write-Host -f DarkGray
    $path.FullName
}
''
if ($args){
'%WL list file'|Write-Host -f DarkGray
    $list = [IO.FileInfo]$args[0]
    $list.Name
''
'%P source path'|Write-Host -f DarkCyan
    $cleanSource = $args[1] -replace '^.*::','' -replace '[\\/]$',''
    $source = [IO.DirectoryInfo]$cleanSource
    $source.FullName

'%T target path'|Write-Host -f DarkCyan
    $cleanTarget = $args[2] -replace '^.*::','' -replace '[\\/]$',''
    $target = [IO.DirectoryInfo]$cleanTarget
    $target.FullName
}
''
if ($args -and $list.length -le 2){
    Write-Warning '%WL list file is empty, exiting...'
    sleep -seconds 3
    exit
}

# read input list file and collect items
$items = @([IO.File]::ReadLines($list.FullName)|foreach{
   if(-not [string]::IsNullOrWhiteSpace($_)){
       $_
   }
})

if (-not $items.count){
    Write-Warning '%WL list file contains no items, exiting...'
    sleep -seconds 3
    exit
}

# process items from %WL list file
'processing {0} items from %WL list file...' -f $items.count|Write-Host -f Yellow

foreach ($item in $items){

$cleanItem = $item -replace '^.*::','' -replace '[\\/]$',''

# MAKE URL FILE(S)

$URL = $cleanItem

# 1.1. REGULAR URL OR NATIVE LOCALHOST URL

# display current URL
'URL={0}' -f $URL
# URL file contents
    $text=[Text.StringBuilder]::new()
    [void]$text.AppendLine('[InternetShortcut]')
    [void]$text.AppendLine("URL=$URL")
# URL file destination path and naming
    $base = Split-Path $cleanItem -leaf
        if ($cleanItem -like '\\localhost\*') {$base = "$base.localhost-native"} else {$base = "$base.regular-path"}
    $URLfile = [IO.Path]::combine($target.FullName,"$base.url")
# avoid naming collisions
$counter = 1
while ([IO.File]::Exists($URLfile)){
    $URLfile = [IO.Path]::combine($target.FullName,"$base($counter).url")
    $counter++
}
# write URL file
[IO.File]::WriteAllText($URLfile,$text.ToString(),[Text.Encoding]::Unicode)

# 1.2. REGULAR URL OR NATIVE LOCALHOST URL :: URI VERSION

$URL = ([URI]$URL).AbsoluteUri

# display current URL
'URL={0}' -f $URL
# URL file contents
    $text=[Text.StringBuilder]::new()
    [void]$text.AppendLine('[InternetShortcut]')
    [void]$text.AppendLine("URL=$URL")
# URL file destination path and naming
    $base = Split-Path $cleanItem -leaf
        if ($cleanItem -like '\\localhost\*') {$base = "$base.localhost-native.uri"} else {$base = "$base.regular-path.uri"}
    $URLfile = [IO.Path]::combine($target.FullName,"$base.url")
# avoid naming collisions
$counter = 1
while ([IO.File]::Exists($URLfile)){
    $URLfile = [IO.Path]::combine($target.FullName,"$base($counter).url")
    $counter++
}
# write URL file
[IO.File]::WriteAllText($URLfile,$text.ToString(),[Text.Encoding]::Unicode)

# 2. MADE-UP LOCALHOST URL BY SUBSTITUTION

# OneDrive and localhost literal definitions
$OneDrive  = 'd:\OneDrive'
$localhost = '\\localhost\OneDrive'

# URL address: if item is within $OneDrive change it to $localhost
if($cleanItem -like "$OneDrive\*"){
    $URL = $cleanItem.Replace($OneDrive,$localhost)

# 2.1. MADE-UP LOCALHOST URL

# display current URL
'URL={0}' -f $URL

# URL file contents
    $text=[Text.StringBuilder]::new()
    [void]$text.AppendLine('[InternetShortcut]')
    [void]$text.AppendLine("URL=$URL")
# URL file destination path and naming
    $base = Split-Path $cleanItem -leaf
    $base = "$base.localhost-made-up"
    $URLfile = [IO.Path]::combine($target.FullName,"$base.url")
# avoid naming collisions
$counter = 1
while ([IO.File]::Exists($URLfile)){
    $URLfile = [IO.Path]::combine($target.FullName,"$base($counter).url")
    $counter++
}
# write URL file
[IO.File]::WriteAllText($URLfile,$text.ToString(),[Text.Encoding]::Unicode)

# 2.2.  MADE-UP LOCALHOST URL :: URI VERSION

$URL = ([URI]$URL).AbsoluteUri

# display current URL
'URL={0}' -f $URL

# URL file contents
    $text=[Text.StringBuilder]::new()
    [void]$text.AppendLine('[InternetShortcut]')
    [void]$text.AppendLine("URL=$URL")
# URL file destination path and naming
    $base = Split-Path $cleanItem -leaf
    $base = "$base.localhost-made-up.uri"
    $URLfile = [IO.Path]::combine($target.FullName,"$base.url")
# avoid naming collisions
$counter = 1
while ([IO.File]::Exists($URLfile)){
    $URLfile = [IO.Path]::combine($target.FullName,"$base($counter).url")
    $counter++
}
# write URL file
[IO.File]::WriteAllText($URLfile,$text.ToString(),[Text.Encoding]::Unicode)

} # end of if -like "$OneDrive\*"

}
''
# finalize
$time.Stop()
'{0} items processed for {1:mm\:ss\.fff}' -f $items.count,
$time.Elapsed|Write-Host -f DarkCyan
'by {0}' -f $MyInvocation.MyCommand.Name
sleep -seconds 7
  • Running within "d:\OneDrive\00-Sync\Total" path under TC, the command/script produces four .URL shortcuts (*.regular-path.url, *.regular-path.uri.url, *.localhost-made-up.url, *.localhost-made-up.uri.url) with the resulting URL=value pairs as follows:
    (with or without $OneDrive to $localhost substitution; with or without $URL = ([URI]$URL).AbsoluteUri conversion)

    Code: Select all

    URL=d:\OneDrive\00-Sync\Total\Test04.png
    URL=file:///d:/OneDrive/00-Sync/Total/Test04.png
    URL=\\localhost\OneDrive\00-Sync\Total\Test04.png
    URL=file://localhost/OneDrive/00-Sync/Total/Test04.png
    
  • Running within "\\localhost\OneDrive\00-Sync\Total" path under TC, the command/script produces two less .URL shortcuts (*.localhost-native.url, *.localhost-native.uri.url) with the resulting URL=value pairs as follows:
    (two less, because $OneDrive to $localhost substitution is inapplicable in that case, since we are already running under \\localhost; the resulting .URL shortcuts, got natively, are identical to the corresponding made-up ones listed above, got via $OneDrive to $localhost substitution)

    Code: Select all

    URL=\\localhost\OneDrive\00-Sync\Total\Test04.png
    URL=file://localhost/OneDrive/00-Sync/Total/Test04.png
    
  • Under TC, all .URL shortcuts are working as intended:
    - Upon double click, Test04.png is being opened in an associated application (FastStone Image Viewer in my case).
    - Upon Ctrl+Q , Test04.png is being previewed in the TC Quick View Panel (via Imagine plugin in my case).
  • Under Windows Explorer, though, only the regular-path-based .URL shortcuts (*.regular-path.url, *.regular-path.uri.url) with "URL=d:\OneDrive\00-Sync\Total\Test04.png" and "URL=file:///d:/OneDrive/00-Sync/Total/Test04.png" values are being opened upon double click, in my case.
  • Essentially the same picture is seen in my case when I make .URL shortcuts to the "d:\OneDrive\00-Sync\Total" directory:

    Code: Select all

    URL=d:\OneDrive\00-Sync\Total
    URL=file:///d:/OneDrive/00-Sync/Total
    URL=\\localhost\OneDrive\00-Sync\Total
    URL=file://localhost/OneDrive/00-Sync/Total
    
#278521 User License
Total Commander [always the latest version, including beta] x86/x64 on Win10 x64/Windows 11/Android 17
Post Reply