Compare files extension PowerShell script assumes all tools are installed in %ProgramFiles%

Advertisement

andydegroo
Joined:
Posts:
1

Compare files extension PowerShell script assumes all tools are installed in %ProgramFiles%

I was baffled why all of a sudden there's error "Cannot find WinMerge" when using File Custom Commands > Compare Files. Went to investigate the PowerShell script CompareFiles.WinSCPextension.ps1 and discovered that it's looking for comparison tool executables in $env:ProgramFiles or $env:ProgramW6432 and doesn't even try to use $env:PATH or PowerShell built-in Get-Command.

The issue is that I've installed WinMerge using winget for my user only in user programs directory – %LocalAppData%\Programs\Winmerge.
This is not a one-off or edge case because any program could be installed as a user-only install or installed anywhere on the system, like when using Scoop package manager applications reside under %UserProfile%\scoop\apps and executable shims are placed in %UserProfile%\scoop\shims directory which is added to %PATH%.
To add to the point, my WinSCP install is in %LocalAppData%\Programs\WinSCP and added to the PATH.

IMHO, the script should use Get-Command to check if the selected tool is in %PATH% and have an option to specify full path for a tool in the custom command settings UI.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,506
Location:
Prague, Czechia

Re: Compare files extension PowerShell script assumes all tools are installed in %ProgramFiles%

Thanks for your post.

I have added this request for PATH search to the tracker:
Issue 2316 – Search for file compare tools in PATH
You can vote for it there.

As for the custom path configuration: If you want to use a custom path, just add a custom command for it. The only point of the extension is that it locates the file compare tools automatically. If it cannot do that, there's no point for you to use it.

Reply with quote

Advertisement

You can post new topics in this forum