#Tauri api to get the "Program Files" path?
52 messages ยท Page 1 of 1 (latest)
Why do you want that folder? Because in 99.9% of cases when people want that folder it's because they're doing something wrong
Hahahah thats fair! I work at a startup where we need to mimic some behavior of a specific microsoft product. After reverse engineering that product, we found that to do a certain thing (which is also the main feature, so theres no "should we" when mirroring the behavior) that product reaches its grubby hands into the Program Files to execute a specific exe if it exists. This odd and invasive behavior happens in a few other cases. Like reaching into the AppData Local of a different application
so blame the man himself, I'm just doing what they do
Well getting the path to C:\Program Files is easy. I just did it right there x)
You can just hard code that path because that folder should always be in that place. So something like let program_dir = Path::from("C:/Program Files")
There may be 12 people out there with a computer that doesn't have it on C:. Don't worry about them
Hmmm I had a feeling that would be the case
the path is not hard to "guess", I was worried about Program Files vs Program Files (x86)
or whatever the number should be
also our users might be some of those 12 since they might run it from a hosted machine with exotic mounting (thanks azure)
But that'll be their problem, I guess
Even with "exotic mounting" the OS desperately wants C to be the system drive. Maybe you haven't done a lot of system repair or dual booting, but if you have windows on 2 hard drives on the same computer and boot into them, they'll both have their system on the C drive
Like it's not just a matter of having a weird drives setup, it's a matter of changing fairly intimite stuff about the system to make it accept anything other than C
Not sure what is the equiv in other systems
And yes, other systems have similar paths you can get, like/Applicationson Mac or/usr/binon Linux, but it's not quite as simple on those systems to say it's a 1-1 mapping with Program Files
There are only those 2 folders btw for program files. Program Files is for 64-bit software and x86 is for 32-bit software. People really don't have anything other than those 2
They can have apps elsewhere for other reasons though
Like in AppData
"maybe", I'm a web developer co-opted into writing native applications. All my system repair experience is on my own machine lol
Thanks for the info, it gives me much more confidence "hard-coding" the path in
Much appreciated
@charred echo
oh, I am using it on the ts side. how can I resolve C:? just like that?
resolve("C:", "Program Files", "Password Manager", "raw-passwords.csv")
?
I so rarely touch the TS side for things like this, but I want to say yes
Legitimate, it does fit better on the rust side.
I am one of the mad lads that advocate the idea that when you make a Tauri app you should develop it as if it had been a Rust CLI application, you're just using the provided webview for input/output, all logic actually resides in the Rust end ๐
Thats how it started, but I was too slow to justify it...
Messing with channels, async, arc, mutex, moving, cloning, and all of that with errors that are still hard for me to read and in a style I'm still not acustomed to
Everything I did in 3-4 weeks in rust I ported in a single day to the ts side. (I still have bindings to the rust layer, but lets say that the "business logic" is in typescript)
thankfully I have effect-ts
This is on me, not on rust.
Though I would say that rust is more C++ than C#
if you get what I mean
I would say Rust is more TS than anything honestly after having used it a while ๐
Or at least I recognize myself most in TS when I use it
Which is probably also part of why I like the Rust first approach, because in most cases I feel like I'm developing mostly the same code as I would in TS, just that if I do it in TS the result is worse
ts would never make me wrangle pointers and moving references ๐น
yes yes multi thread concurrency and so on. It makes total sense
but it's more ritual than anything
Rust doesn't make you do that either, well, mostly, once you figure out the ownership system
I did get the hang of it as time went on, but things like spinning a server on demand that dies in 90s or when it gets a specific request or manually or if someone tries to spin a new one was a nightmare
Since the server can only shut down by resolving some callback value, the obvious solution is a channel. I'll skip to the end to not bore you too much, I needed an Arc<Mutex<Option<Sender>>> to be able to move it around the place safely
Don't get me wrong, it makes perfect sense, but it was so tedious to get there ๐ข
Yea it's totally fair that stuff like that is needed here and there. In most cases in Tauri you can skip the arc if you instead store it in a State, but yea. It takes a while for all of these sort of things to feel natural for sure
New roardblock. How can I execute these? I thought that they would work like a sidecar, but looking at it more, I don't think it'll be that simple. For example, how do I tell tauri to even run them if they are not in my binaries folder lol
Yes, what should I invoke?
import { Command } from '@tauri-apps/api/shell';
const command = new Command('node');
command.on('close', data => {
console.log(`command finished with code ${data.code} and signal ${data.signal}`)
});
command.on('error', error => console.error(`command error: "${error}"`));
command.stdout.on('data', line => console.log(`command stdout: "${line}"`));
command.stderr.on('data', line => console.log(`command stderr: "${line}"`));
const child = await command.spawn();
console.log('pid:', child.pid);
Command("C:/Program Files/Bank App/transferFunds.exe", ["to", "me"])?
Yep
import { resolve, appDataDir } from '@tauri-apps/api/path';
const appDataDirPath = await appDataDir();
const path = await resolve(appDataDirPath, '..', 'users', 'tauri', 'avatar.png');
You can use stuff like this when you resolve the path
I don't believe you can use it in the command
You should be able to use OS level variables though
I meant in the tauri.conf.json (or rather Tauri.toml in my case)
since commands are required to be specified by a scope
also not clear if I can use forward slashes instead of backslashes when defining the scopes, though I just persume that it's fine
Test it and see. Should be fine