Simplify shortcut args
This commit is contained in:
parent
ba5a8ac31b
commit
3e7149f880
|
@ -194,18 +194,9 @@ impl<'a> Step<'a> {
|
|||
}
|
||||
ShortcutTarget::Executable { file: exec_file, args } => {
|
||||
use std::fmt::Write;
|
||||
let mut args_str = String::new();
|
||||
let mut args = args.into_iter();
|
||||
if let Some(arg) = args.next() {
|
||||
// TODO: quote properly
|
||||
write!(args_str, "{:?}", arg).unwrap();
|
||||
}
|
||||
for arg in args {
|
||||
write!(args_str, " {:?}", arg).unwrap();
|
||||
}
|
||||
tokio::process::Command::new("powershell")
|
||||
.arg("-Command")
|
||||
.arg(format!(r#"$shell = New-Object -ComObject WScript.Shell; $shortcut = $shell.CreateShortcut({file:?}); $shortcut.TargetPath = {exec_file:?}; $shortcut.Arguments = {args_str:?}; $shortcut.Save()"#))
|
||||
.arg(format!(r#"$shell = New-Object -ComObject WScript.Shell; $shortcut = $shell.CreateShortcut({file:?}); $shortcut.TargetPath = {exec_file:?}; $shortcut.Arguments = {args:?}; $shortcut.Save()"#))
|
||||
.stdout(std::process::Stdio::inherit())
|
||||
.stderr(std::process::Stdio::inherit())
|
||||
.status()
|
||||
|
@ -249,7 +240,7 @@ pub enum ShortcutTarget<'a> {
|
|||
file: Cow<'a, Path>,
|
||||
|
||||
/// Arguments to the executable.
|
||||
args: &'a [&'a str],
|
||||
args: &'a str,
|
||||
},
|
||||
|
||||
/// A file or folder shortcut. Please use [`Self::Executable`] for shortcuts to binaries.
|
||||
|
|
|
@ -65,7 +65,7 @@ async fn main() -> Result<()> {
|
|||
target: ShortcutTarget::Executable {
|
||||
file: nppp_dir.join("notepad++.exe").into(),
|
||||
|
||||
args: &[],
|
||||
args: "",
|
||||
},
|
||||
file: desktop_path().join("Notepad++.lnk").into(),
|
||||
},
|
||||
|
@ -88,7 +88,7 @@ async fn main() -> Result<()> {
|
|||
target: ShortcutTarget::Executable {
|
||||
file: epp_dir.join("Explorer++.exe").into(),
|
||||
|
||||
args: &[],
|
||||
args: "",
|
||||
},
|
||||
file: desktop_path().join("Explorer++.lnk").into(),
|
||||
},
|
||||
|
@ -105,7 +105,7 @@ async fn main() -> Result<()> {
|
|||
target: ShortcutTarget::Executable {
|
||||
file: minecraft_dir.join("Minecraft.exe").into(),
|
||||
|
||||
args: &[],
|
||||
args: "",
|
||||
},
|
||||
file: desktop_path().join("Minecraft.lnk").into(),
|
||||
},
|
||||
|
@ -126,7 +126,7 @@ async fn main() -> Result<()> {
|
|||
target: ShortcutTarget::Executable {
|
||||
file: Path::new("C:\\WINDOWS\\system32\\cmd.exe").into(),
|
||||
|
||||
args: &["/C", "powershell"],
|
||||
args: "/C powershell",
|
||||
},
|
||||
file: desktop_path().join("PowerShell.lnk").into(),
|
||||
}],
|
||||
|
|
Loading…
Reference in New Issue