You could try to make the WPF application to Run in Administrator Mode and then published it.
- Open the Solution Explorer
2.Right CLick on the solution--->Add---->New Item---->App.Manifest---->OK
3. Edit the Manifest file as follows:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
(TO)
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
4.After editing the Manifest file, Goto Solution project(RightCLick)------>properties------->Security
Turn out the Checkbox of "Enable ClickOnce Security Settings"
Run the Application, and Take setup, Now the application with Run as Administrator mode is achieved.
Complete code:
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
Add the app.manifest file to project, and then ensure the .csproj file contains
<ApplicationManifest>app.manifest</ApplicationManifest>
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.