From 0dd056fbc43e8586fddf2389f42a1e4f28476187 Mon Sep 17 00:00:00 2001 From: Dorian Eikenberg Date: Thu, 30 Dec 2021 14:06:31 +0100 Subject: [PATCH] Set shortcut run property to minimized --- Cargo.toml | 2 +- src/link.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d61f892..c7a1cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ampsim-launcher" -version = "0.1.1" +version = "0.1.2" edition = "2021" [dependencies] diff --git a/src/link.rs b/src/link.rs index 89d679c..6c93006 100644 --- a/src/link.rs +++ b/src/link.rs @@ -1,12 +1,18 @@ use std::path::Path; -use mslnk::ShellLink; -use stable_eyre::Result; +use mslnk::{ShellLink, ShowCommand}; +use stable_eyre::{eyre::bail, Result}; pub(crate) fn make_link(target: &Path, location: &Path) -> Result<()> { let mut link = ShellLink::new(std::env::current_exe()?)?; link.set_arguments(Some(format!("-e launch \"{}\"", target.to_string_lossy()))); + match target.parent() { + Some(parent) => link.set_working_dir(Some(parent.to_str().unwrap().to_string())), + None => bail!("Unable to determine parent directory of shortcut target"), + } link.set_icon_location(Some(target.to_str().unwrap().to_string())); + link.header_mut() + .set_show_command(ShowCommand::ShowMinNoActive); link.create_lnk(location.with_extension("lnk"))?; Ok(())