Technical Anshu
Tutorials Blog
Admin Rights Option

Require Admin Rights in a Converted EXE With the requireAdmin Option

Nothing looks worse than a repair tool that starts confidently and dies on its third change with access denied. The -requireAdmin option moves that moment to the launch, as one clean UAC question. But elevation is a cost charged on every run - this page covers when to pay it and when asking is the wrong design.

By Technical AnshuWindows 10 / 115 minute read
Watch the video to see where this option sits in the conversion

A converted tool runs exactly like the script inside it - including the moment the script reaches for something only an administrator may touch. Unelevated, that moment is a confusing mid-job failure. The manifest option exists to turn it into an honest question asked up front. Like every powerful checkbox, though, it has a user cost, and this page weighs both sides before you tick it.

User Account Control - the prompt a requireAdmin build produces
User Account Control
Do you want to allow this app to make changes to your device?
DiskCleanup.exe - Verified publisher shown when the file is signed
Yes / No - the user decides once, at launch, before anything runs
The prompt the user sees at start-up. With -requireAdmin it appears every launch - so only ask when the tool truly needs it.
1

What the Option Actually Does

-requireAdmin writes a request into the EXE's manifest - the small declaration Windows reads before starting a program. It tells Windows: this program needs administrator rights, every time. Windows responds by showing the UAC prompt at launch. If the user accepts, the whole program runs elevated from its first line. If they decline, the program does not run at all.

That is a very different behaviour from a script that starts unelevated and fails halfway through with access-denied errors on the third change it tries to make. The failure moves to the front door, where it belongs, and it arrives wearing a clear question instead of a red error.

2

When a Script Genuinely Needs It

  1. Changing machine-wide settings - services, drivers, system files, anything under HKLM in the registry
  2. Writing to protected locations such as Program Files or other users' profiles
  3. Repair and cleanup jobs - the classic admin toolbox work this kind of tool usually does

The conversion line is the stage-3 command plus one word: Invoke-PS2EXE -inputFile ".\Cleanup.ps1" -outputFile ".\Cleanup.exe" -requireAdmin. In the Win-PS2EXE GUI it is the requireAdmin checkbox.

3

When Asking Is the Wrong Design

Elevation is a cost you charge the user on every single run, so spend it only where the work demands it. A tool that reads information, fixes the current user's own settings, or works inside their own folders does not need admin rights - and asking anyway causes real harm:

  1. On office and school PCs, users often have no admin password to give - your helpful tool simply refuses to run for exactly the people it was built for
  2. Asking for elevation constantly trains people to click Yes without reading, which devalues the one prompt that protects them
  3. An elevated program that launches other things passes its rights along - your little tool becomes a door

The mature pattern is two tools, not one greedy one: a normal version for everything user-level, and a clearly named admin version for the rare machine-level job.

4

A Middle Path Worth Knowing

If only one small part of the job needs elevation, keep the main tool unelevated and let that one part ask - a script can start a single elevated helper command with Start-Process -Verb RunAs and continue unelevated itself. The user sees one prompt for one explained action, not a blanket grant for the whole session. Whichever pattern you choose, decide it before conversion: the manifest is baked in at build time, so changing your mind means rebuilding the EXE.

Watch the Complete Process in the Video

Watch the video for the conversion with this option in context, then decide per tool - not by habit.

Watch Full Video
Frequently Asked Questions

Does requireAdmin store or ask for the admin password itself?

No. The option only makes Windows show its own UAC prompt. The user (or an admin standing beside them) types credentials into Windows' own secure screen, and your program never sees or handles the password. If the user has no admin rights to offer, the program simply does not start.

My EXE already runs as admin when I right-click and choose Run as administrator. Why bake it in?

Because your users will not remember the right-click. Baking it in makes the correct behaviour the only behaviour - the prompt appears on every normal double-click launch. The right-click route remains as a manual equivalent for scripts you have not converted.

Can one EXE contain both behaviours - normal start, elevation only when needed?

Not through the manifest: it is set at build time for the whole program. The workaround is architectural - keep the main EXE unelevated and have the one admin-only action start a small elevated helper (for example with Start-Process -Verb RunAs), so elevation is requested for that step alone.

This guide is based on the Technical Anshu PowerShell to EXE video - Stuck on any step? Ask in the video comments and you will get a reply there.