0

As the title says, I am wondering if there is a way to start my program in administrative mode using a function, code, command of some sort included in it. The reason is, my program cannot delete a file without having to be run as an administrator. and yes a simple way of solving this would be to edit the properties of the exe so that it uses UAC to start as admin but I have to distribute the source code for my reviewers to compile it and wanted to save them the trouble.

Any comments,solutions etc are appreciated, thanks.

Helper Shoes
  • 133
  • 7
  • Does this answer your question? [How do I force my .NET application to run as administrator?](https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator) – Daniel A. White Jan 03 '22 at 01:25

1 Answers1

2

You could use PowerShell for this:

PowerShell Start yourprogram.exe -Verb Runas

This should be portable enough to run on most Windows systems.

Cheatah
  • 1,825
  • 2
  • 13
  • 21