#replace #self-update #self-uninstall #uninstall

self-replace

Utility crate that allows executables to replace or uninstall themselves

10 stable releases

new 1.3.7 Sep 19, 2023
1.3.6 Aug 25, 2023
1.3.5 Jun 3, 2023
1.3.3 May 19, 2023

#247 in Filesystem

Download history 385/week @ 2023-06-05 485/week @ 2023-06-12 360/week @ 2023-06-19 130/week @ 2023-06-26 192/week @ 2023-07-03 132/week @ 2023-07-10 328/week @ 2023-07-17 205/week @ 2023-07-24 248/week @ 2023-07-31 205/week @ 2023-08-07 157/week @ 2023-08-14 341/week @ 2023-08-21 338/week @ 2023-08-28 1651/week @ 2023-09-04 1994/week @ 2023-09-11 14031/week @ 2023-09-18

18,120 downloads per month
Used in 7 crates (2 directly)

Apache-2.0

26KB
281 lines

Self-Replace: A Utility For Self Replacing Executables

Build Status Crates.io License rustc 1.48.0 Documentation

self-replace is a crate that allows binaries to replace themselves with newer versions or to uninstall themselves. On Unix systems this is a simple feat, but on Windows a few hacks are needed which is why this crate exists.

This is a useful operation when working with single-executable utilties that want to implement a form of self updating or self uninstallation.

For details about the implementation refer to the documentation.

Uninstall

To uninstall a binary, use self_delete.

self_replace::self_delete()?;

Updating

To replace a binary for updating, use self_replace.

let new_binary = "/path/to/new/binary";
self_replace::self_replace(&new_binary)?;
std::fs::remove_file(&new_binary)?;

Dependencies

~0.1–13MB
~136K SLoC