administrator

Admin rights for a single method

你说的曾经没有我的故事 提交于 2019-11-26 06:14:35
问题 Is it possible to require administrator rights for one single method? Something like this: [RequireAdminRightsForThisMethod()] private void TheMethod(){ // Do something } 回答1: You can add a PrincipalPermission attribute to your method to demand administrative privileges for its execution: [PrincipalPermission(SecurityAction.Demand, Role = @"BUILTIN\Administrators")] public void MyMethod() { } This is described in more detail in the following article: Security Principles and Local Admin Rights

How to start a new process without administrator privileges from a process with administrator privileges?

江枫思渺然 提交于 2019-11-26 05:58:25
问题 I am creating an automatic updater for an application. The application is started by the user, and runs without administrator privileges. The autoupdater is started with administrator privileges, and kills the application before it downloads the new files. The problem comes when I want to start the updated application after the autoupdater is finished. If I use regular System.Diagnostics.Process.Start(file), the application starts with administrator privileges too, and it has to run on the

Running a command as Administrator using PowerShell?

别等时光非礼了梦想. 提交于 2019-11-26 03:16:09
问题 You know how if you\'re the administrative user of a system and you can just right click say, a batch script and run it as Administrator without entering the administrator password? I\'m wondering how to do this with a PowerShell script. I do not want to have to enter my password; I just want to mimic the right-click Run As Administrator method. Everything I read so far requires you to supply the administrator password. 回答1: If the current console is not elevated and the operation you're

How do I force my .NET application to run as administrator?

落爺英雄遲暮 提交于 2019-11-25 21:37:24
问题 Once my program is installed on a client machine, how do I force my program to run as an administrator on Windows 7? 回答1: You'll want to modify the manifest that gets embedded in the program. This works on Visual Studio 2008 and higher: Project + Add New Item, select "Application Manifest File". Change the <requestedExecutionLevel> element to: <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> The user gets the UAC prompt when they start the program. Use wisely; their