-
How can I allow users to open files with my app via "Open With" on Windows? I have configured a single file association, and it works well. I can open the file with both a double click and the "Open With" menu. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I'm not sure I understand your question exactly, so I can propose 2 things.
With more context, it may be easier to answer. |
Beta Was this translation helpful? Give feedback.
-
So if I understood correctly, you want it so that, for example, if you have The reason why your app "Starts" and then closes suddenly is because it doesn't know how to handle the arguments passed to it from using "Open With". When using "Open With", Windows passes the opened file as a command-line argument to your app. Even if fn main() {
let args: Vec<String> = std::env::args().collect();
// Print them so you can see exactly what is being passed, and how to process them.
// I would strongly suggest logging this to some text file as well
println!("Args: {:?}", args);
// This may print something like: "["C:\\Path\\To\\Your\\App.exe", "C:\\Users\\You\\test.xsd"]"
if let Err(e) = tauri::Builder::default().run(tauri::generate_context!()) {
// Write the error to a file
if let Ok(mut file) = File::create("error_log.txt") {
let _ = writeln!(file, "Startup Error: {}", e);
}
// Quit the app with an error code
exit(1);
}
} I suspect your app is erroring out and instantly closing, making it impossible to read the error. This way, you'll have a text log you can use to trace the error. If you can get this to run on your own code, feel free to paste here what kind of error you're getting when trying to run your app using "Open With". It'll be easier to debug this way. |
Beta Was this translation helpful? Give feedback.
OMG, the issue was completely unrelated to Tauri and was really dumb...
For some reason, the "Open With" menu option with my app was pointed to
src-tauri/target/...
and not to theC:/Users/user/...
. That is why I have been getting those errors.I cleaned up my project, reset file associations, restarted the OS, and now everything works just fine.
Sorry for the confusion.