How can I add /MANIFESTUAC:level='requireAdministrator'
to a specific windows binary in Cargo.toml in a multi-binary package?
1 Like
I think the more general question is: What is the easiest way to add a specific linker option to a specific binary target in a multi-binary package under a specific target triple?
1 Like
Update: I just tried this in build.rs
fn main() {
#[cfg(windows)]
println!("cargo:rustc-link-arg-bin=install=/MANIFESTUAC:level=\'requireAdministrator\'");
}
However, the output binary still seems to be executing with normal user privileges...
You probably also want to add /MANIFEST:EMBED
. E.g.:
println!("cargo:rustc-link-arg-bin=install=/MANIFEST:EMBED");
1 Like
Wow! Thank you very much! This does fix this problem!
My final working build.rs is like:
fn main() {
#[cfg(windows)]
{
println!("cargo:rustc-link-arg-bin=install=/MANIFEST:EMBED");
println!("cargo:rustc-link-arg-bin=install=/MANIFESTUAC:level=\'requireAdministrator\'");
}
}
2 Likes
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.