Skip to main content

open_with_verb

Function open_with_verb 

Source
pub fn open_with_verb(verb: &str, target: impl AsRef<Path>) -> Result<()>
Expand description

Opens a file or directory using a specific Windows shell verb.

Common verbs include open, edit, print, and properties, depending on what the target path’s registered handler supports.

§Errors

Returns Error::InvalidInput if verb is empty, whitespace only, or contains NUL bytes, or if target is empty. Returns Error::PathDoesNotExist if the target path does not exist. Returns Error::WindowsApi if ShellExecuteW reports failure.

§Examples

win_desktop_utils::open_with_verb("properties", r"C:\Windows\notepad.exe")?;
Examples found in repository?
examples/open.rs (line 2)
1fn main() -> Result<(), win_desktop_utils::Error> {
2    win_desktop_utils::open_with_verb("properties", r"C:\Windows\notepad.exe")?;
3    win_desktop_utils::open_url(" https://www.rust-lang.org ")?;
4    Ok(())
5}