Admin Rights Win 8+ and LNK-Library

Hello,

only a short question, i hope:). How can i compile a executable in rust that automaticly triggers the UAC and gives admin rights to the exe?

In Micosoft Studios he wants an manifest xml file.

And knows anybody a good crate lib that handle windows .lnk files?

Greetz

This has been asked before

What do you mean by “handle” them? There’s RustyLnk, but I can’t seem to find a crates.io page.

thx for the infos.
It looks like i must scooooop in the code of RustyLnk and snag the code i needed:). But an crate i don’t have found, too.

@OptimisticPeach The thread don’t answer my problem. I want to make the rust executables that trigger the uac and request admin rights, i don’t call an adminexecutable from an rust executable. When user start my executable i wants that the uac-prompts request an admin right.

You don’t need to copy it actually, you can add it as a dependency like so:

# Your Cargo.toml
RustyLnk = { git = "https://github.com/forensicmatt/RustyLnk.git" }

@OptimisticPeach Thx, i will try it, unfortunately there is no api-doc and i think there only convert to json, but i hope i can use the binary-datas and copy it back again to an .lnk file.

You need a manifest file, and you need a resource file to embed the manifest file. There are a couple crates out there for compiling and linking resource files.

@retep998 Thx, do you have some crate-links, that will be nice?

Edit: Ah i see your winres-crate do the things i need, i have to go to your documentation, there stand it:).

Some Additions to check if the user has admin rights:

fn checkAdmin()
	{
		use std::fs;
		use std::fs::File;
		let testfile = format! (r"{}\{}",env::var("WinDir").unwrap(),r"admin.testfile");
		let mut f = File::create(testfile);
		match f.as_ref()
		{
			Ok(f) =>
			{
				println!("{:?}", "Admin");
			},
			_ =>
			{
				println!("{:?}", "NoAdmin");
			},
		}
	}

Not the most elegant way but its functioned at the moment.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.