Skip to content

Lightweight shims for executable files help to keep your dev and admin tools organized

License

Notifications You must be signed in to change notification settings

turboBasic/shimPsy

Repository files navigation

0xHexagram

Simple shim creator: select one directory referenced in your $ENV:PATH and create here shims (shortcuts on steroids) to your favourite programs

FAQ

What is shimPsy?

shimPsy is a wrapper for shimgen.exe shim generator provided with Chocolatey package manager

What is shim?

Shim is a shortcut to executable file. Actually it is a shortcut on steroids. Basically it is YourProgram.exe which looks and behaves the same as your original program, but located in another place(s) on your disk. There exists even more verbose explanation

What is shim for?

for making your Windows configuration simpler, better and easier to replicate. You can collect shims to your command-line and GUI programs in one location, shortening you $ENV:PATH, improving speed of search of programs and avoiding calling old/other versions of programs

How do I use shims?

  • you choose the place where your shims are going to live. Basically Shimpsy chooses it automatically if you have Scoop or Chocolatey package manager installed

  • you make sure that this location is in your PATH environment variable. That's why ~\scoop\shims and c:\ProgramData\chocolatey\bin are good candidates as they are already in. ~\scoop\shims is particularly good as creating shims there doesn't require elevating privileges and doesn't impact other users of computer. Sometimes your intention is opposite: to have shims in read-only state for users and applicable to everyone, in this case Chocolatey dir is preferable. You can even create your own b:\tools directory, add it to PATH and you are done

  • Check how many directories are mentioned in System and User PATHs: they tend to inflate when apps forget/neglect to remove their dirs after uninstallation or being agressively abused and filled in with lots of directories by others. Create shims by invoking shimpsy <path to .exe>

Why shim is better than .lnk shortcut?

shortcut.lnk is for graphic (GUI) mode only, like creating icon on a desktop pointing to your application. shim.exe created by shimPsy behaves exactly as original program both in GUI and command-line

Why shim is better than symlink or hardlink?

  • until recently Windows allowed to create symlinks for administrator user only
  • hardlinks cannot cross the disks boundaries, i.e. you can't have c:\tools\program.hardlink.exe pointing to d:\program.exe

I can't believe that Windows do not have any native utility for generating shims, is it true?

Yes, it is. System administration practices in Windows have been very different from the rest of the World of Operating systems for too long period of time. Nothing similar to /usr/local/bin or Linux' Filesystem Hierarchy Standard has existed which led to applications race for preferred position in PATH, too lengthy PATH and inability to maintain several versions of applications etc. Happily, Windows is moving in right direction in this regard especially starting with Windows 10 era

Are there any alternatives to shimPsy or, well, shimgen.exe?

Yes there is at least one known to me: Scoop's shim.ps1. I like it as it is very simple and works as expected, but the shims generated by it are coupled with individual .ini file and you cannot inject an icon inside. It has an Open Source license, so you can modify it for your personal needs

Why should I use shimPsy and not original shimgen.exe?

  • There is an opinion that shimgen.exe is too wordy for 95% of use cases and too abusive to the user's keyboard. I would rather have simpler alternative which can read defaults from stored settings than provide the list of options every time I run it

  • If you have Chocolatey installed you can definitely use shimgen.exe. Unfortunately it is hidden from the default path by Chocolatey installer

  • The creators of shimgen.exe provide it with the license which allows only free use of .exe file and no right to distribute. I find its usefulness way broader than being a hidden tool inside otherwise beautiful package manager

  • All mentioned above is passively limiting usage of shims, it should be a best practice for Windows

  • In case if Chocolatey installation is found, shimPsy just shims shimgen.exe in its shim directory (don't try to repeat it in voice) and only if there is no one it fetches shimgen.exe from the web. I think this is more friendly for Chocolatey and helps to save some bandwith

Definitions

Chocolatey
The package manager for Windows
Scoop
A command-line installer / super light-weight package manager for Windows
shim
Citing Wikipedia, shim is

a small library that transparently intercepts API calls and changes the arguments passed, handles the operation itself, or redirects the operation elsewhere. Shims can be used to support an old API in a newer environment, or a new API in an older environment

or, in oversimplifying terms, an executable file which runs program located elsewhere as it has been run from current working directory. Comparing with command/batch files it doesn't need a new copy of shell's process launched to interpret commands. This often leads to resetting environment to defaults values in the new process and as result, the program works in different environment than user's one, leading to hardly intercepted misbehavior

About

Lightweight shims for executable files help to keep your dev and admin tools organized

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published