Create portable shortcuts on a USB drive.
Sometimes, you have to do development work on multiple machines without admin access.
One method is to install your environment onto a USB drive, then run the programs
off of it. However, on different computers, Windows can assign different drive
letters to a USB drive based on how many drive letters the system already has
in use. This makes it very tricky to use simple shortcuts, though there are
workarounds,
which usually rely on the fact that a path like \foo\bar
will be assigned the
drive letter of the current working directory.
However, there are two shortcomings with the standard workarounds:
- Some programs don't handle missing drive letters well
- This method makes it hard to manage envrionment variables (particularly
PATH
)
This program uses Rust to generate and build executables that can intelligently
configure the correct PATH
and other environment variables, then launch a program
from a USB drive, regardless of drive letter.
- Clone the project onto the USB drive you plan on deploying to
- Edit
assets/config.toml
as necessary - Run
cargo build && cargo build && cargo run --bin portable-shortcuts
. Yes, really. Explanation below.
Building and deploying is a 3-step process:
- Build the project. This runs
build.rs
, which parsesassets/config.toml
, generating the source for each shortcut and leaving them insrc/bin
. However, because Cargo determines build targets before runningbuild.rs
, the generated source files don't actually get built. - Build the project again. This (probably) doesn't run
build.rs
again, but it does build all of the things insrc/bin
. - Run the built portable-shortcuts file. This reads
assets/config.toml
again and copies the built shortcuts from step 2 into their correct locations.
The template used for each shortcut is in assets/template.rs
.