tl;dr: What you are attempting to do is not possible in the way you want to do it. Fortunately, ShimGenerator can do this exact thing (that's what it was designed for and it comes with Chocolatey):
& "$env:ChocolateyInstall\tools\shimgen.exe" --output="$env:ChocolateyInstall\bin\vlc.exe" --path=" C:\Program Files\VideoLAN\VLC\vlc.exe" -iconpath="C:\Program Files\VideoLAN\VLC\vlc.exe"
Why a Symbolic Link (Symlink) Won't Work
Those executables have dependencies that they expect to be relative to the executable. You would need to symlink the file AND all of its dependent files/folders - so in other words you can't simply symlink the file, you would likely need to symlink the directory and put that directory on the PATH, which kind of defeats the purpose you are trying to achieve.
Shimming is a Better Way
Chocolatey creates shims when it finds executables in package directories. Symlinks fall down when the files have dependencies (as you are seeing).
We've wrote more about it at https://chocolatey.org/docs/features-shim#benefits (emphasis mine):
These are the benefits of creating a shim:
- Provides an exe file that calls a target executable.
- Runs the target executable where it is, which means all dependencies and other things used are all in the original location
- When items require elevated privileges, shims will raise UAC prompts.
- The exe can be called from powershell, bash, cmd.exe, or other shells just like you would call the target.
- Blocks and waits for command line apps to finish running, exits immediately when running a GUI app.
- Uses the icon of the target if the target exists on creation.
- Works better than symlinks. Symlinks on Windows fall down at file dependencies. So if your file depends on other files and DLLs, all of
those need to also be linked.
- Does not require special privileges like creating symlinks (symbolic links) do. So you can create shims without administrative rights.
If symlinks worked better, we would have probably used them instead of spending the amount of time we did working on shimgen. There is an FAQ on the shim feature page as well.
Shimming in Chocolatey Packages
Chocolatey automatically creates shims when executables are found in the package directory.
You can also do this in
chocolateyInstall.ps1 scripts (in the packaging) with
Install-BinFile. See more details at https://chocolatey.org/docs/helpers-install-bin-file.
How You Can Symlink VLC
To fully symlink VLC, you would also need to symlink the following files and folders (and any subfolders and files in those folders) in addition to just
While I could provide a script to symlink the entire thing, I don't think it is necessary given it is pretty much a futile approach.