uac

Run .NET application as administrator

时光总嘲笑我的痴心妄想 提交于 2019-11-29 21:13:39
问题 Since Vista & windows 7 came out some of my .NET application has started throwing security exceptions. I've noticed that some applications (i.e. my antivirus, control panel) have a small shield and when I run these applications administrator privileges are automatically requested from me by windows. I know that as a user I can set the application to run as administrator but that's not good enough because if the application will run without privileges it would crash on my users machines. Is

How to display UAC prompt for file save to restricted location using c#?

巧了我就是萌 提交于 2019-11-29 18:58:12
问题 When a user saves a file from my application, they currently can't save to restricted locations (like C:). I think this is a good restriction, but I would like to provide a UAC prompt to elevate privileges and allow a user to save in a restricted area. I've seen lots of answers around this topic that involve spawning a new process with elevated privileges using 'runas'. Also, it seems like this can be done by impersonating another user. From what I understand, both of those methods require a

Restarting IIS programmatically

回眸只為那壹抹淺笑 提交于 2019-11-29 15:50:03
问题 I need to restart IIS from a C#/.NET application. This seems like a trivial issue, but I haven't had success thus far, and none of the answers from this question have worked. I am a local administrator on the machine. I've tried this: var process = new Process { StartInfo = { Verb = "runas", WorkingDirectory = @"C:\Windows\System32\", FileName = @"issreset.exe" } }; process.Start(); but this throws a Win32Exception - cannot find the file specified. I've also tried various combinations of

Check if another process has admin privileges in .NET

假如想象 提交于 2019-11-29 14:32:50
I'm looking for a way to check that a remote process has administrator privileges from my (fully managed) code. It's safe to assume that my code will run be run with administrator privileges, so I don't care how invasive the technique to achieve my goal is, however I'm looking for a fully managed way which must be compatible with XP SP3 x86 all the way down to win7 x64. Thanks in advance! Edit : in order to clarify, I'm talking about a process running on the same machine, regardless of the user who started it. I want to make sure that either the identity associated with the process belongs to

Correct way to design around Windows UAC limitations?

久未见 提交于 2019-11-29 14:20:57
问题 I found out an application I wrote does not work properly under Windows Vista/7 if UAC is enabled at any level, because it writes files to the install directory of the program, defaults to "C:\Program Files\MyProgram." If UAC is disabled (or on any other version of Windows) it works properly - I read that UAC denies applications write access to the Program Files directory by default. My question is, well, how should I write my application so that it can be used without any "rights" needed at

Need to elevate permissions without UAC pop ups

烈酒焚心 提交于 2019-11-29 14:17:15
I have an application which is a launcher for another application (my main one). The launcher goes to an FTP server, downloads updates and installs them. However, the update executable needs to copy some DLLs and EXEs to the installation directory of the main application, which is in Program Files. Because of that, I currently need to elevate the rights of the updater. This is a problem because my application starts on boot, and in general will simply load to the system tray (the application is comparable to messenger/skype). If I start popping UAC warnings on the screen while trying to

Run child process non-elevated from an elevated/As Admin process

半世苍凉 提交于 2019-11-29 12:50:14
My application has a built-in self update system via another app called "updater.exe" which is in the same folder with the main application to update. It downloads the newest version, terminates the old one (if it's running) and then overwrites it. The problem is, to do that the updater.exe must be run with the Administrator privileges in order to have access to C:\Program Files\MyApp So far so good, the main app runs the updater.exe with Admin privileges (using UAC) but then the problem appears: After update is completed, I want the new installed version to start automatically. Guess what? Of

How to run another app as administrator on Windows XP

*爱你&永不变心* 提交于 2019-11-29 10:39:40
I used the application manifest file as described here to have a part of my application running with elevated privileges (which it needs). So when needed, the main program just invokes a small assembly using Process.Start which then handles the task for which admin rights are required. However, how can I do the same thing on Windows XP? It seems XP just ignores this manifest and runs the small assembly in the current user context. Marc The following code from here does just what I need: ProcessStartInfo processStartInfo = new ProcessStartInfo("path", "args"); processStartInfo.Verb = "runas";

Looking for Delphi 7 code to detect if a program is started with administrator rights?

 ̄綄美尐妖づ 提交于 2019-11-29 09:13:44
问题 I am looking for working ( obviously ) Delphi 7 code so I can check whether my program is started with administrator rights . Thanks in advance [--- IMPORTANT UPDATE ---] Having reviewed the code in the answers so far, I realise that my question maybe is not so clear, or at least is not complete: I want to know whether my Delphi 7 program is started with the 'Run as admin' check box set . In other words: I want to know whether it is possible for my Delphi 7 program to create/update files in

Running a PowerShell script as administrator without typing in passwords

旧街凉风 提交于 2019-11-29 08:57:52
I wrote a script that will switch between having a computer connect via Wi-Fi or wired Internet simply by running a batch file. I wrote this because I don't like having to type in my username and password to switch between the two every time. NOTE: I HAVE to have UAC enabled so unfortunately just turning it off isn't an option. It looks at the status of the wireless adapter. If it is currently enabled, it will turn off the wireless adapter and enable the wired adapter. If the wireless is not enabled, it will enabled and disable the wired. This is the code. $adapter = Get-WmiObject -Class Win32