How to run external program with admin rights + in specific folder

How to run external program with admin rights + in specific folder, possible?

I don't understand what you want to do, please provide additional details.

Maybe this is what you want to do:

fn main() {
    let mut cmd = std::process::Command::new("bash");
    let output = cmd.args(["-c", "pwd; cd ../; pwd"]).output().unwrap();
    println!("{:#?}", std::str::from_utf8(&*output.stdout).unwrap());

You can run it on Rust Explorer playground.

The command is run by the user that run the rust program. Thus you need to run it as a root user.

In this case the external program is pwd. You can cd to move to the directory from where you want to execute the program.

is this working in windows app?

I need to run program, it must be ran with admin rights because i get error

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 740, kind: Uncategorized, message: "The requested operation requires elevation." }', src\
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[0815/] Failed to unregister class Chrome_WidgetWin_0. Error = 0

You need to run the rust program as administrator.

I believe the command for Windows is

fn main() {
    let mut cmd = std::process::Command::new("cmd");
    let output = cmd.args(["/C", "pwd; cd ../; pwd"]).output().unwrap();
    println!("{:#?}", std::str::from_utf8(&*output.stdout).unwrap());

I'm running Linux, I can't test it for you.

Yes, it's working, but rust program freeze