Skip to main content

shortcuts/
shortcuts.rs

1fn main() -> Result<(), Box<dyn std::error::Error>> {
2    let cwd = std::env::current_dir()?;
3    let notepad = r"C:\Windows\notepad.exe";
4
5    let lnk_path = cwd.join("notepad-demo.lnk");
6    let options = win_desktop_utils::ShortcutOptions::new()
7        .description("Open Notepad")
8        .working_directory(r"C:\Windows")
9        .icon(notepad, 0);
10
11    win_desktop_utils::create_shortcut(&lnk_path, notepad, &options)?;
12    println!("created shortcut: {}", lnk_path.display());
13
14    let url_path = cwd.join("rust-docs.url");
15    win_desktop_utils::create_url_shortcut(&url_path, "https://doc.rust-lang.org/std/")?;
16    println!("created URL shortcut: {}", url_path.display());
17
18    Ok(())
19}