How do you run a command as an administrator from the Windows command line?

All you have to do is use the runas command to run your program as Administrator (with a caveat). runas /user:Administrator “cmdName parameters” In my case, this was runas /user:Administrator “cmd.exe /C %CD%\installer.cmd %CD%” Note that you must use Quotation marks, else the runas command will gobble up the switch option to cmd. Also note … Read more

How to request administrator permissions when the program starts?

Add the following to your manifest file: <requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” /> You can also use highestAvailable for the level. Look here about embedding manifest files: http://msdn.microsoft.com/en-us/library/bb756929.aspx PS: If you don’t have a manifest file, you can easily add a new one: In Visual Studio, right click project -> Add Item -> Choose Application Manifest File … Read more

Detect if running as Administrator with or without elevated privileges?

Try this out: using Microsoft.Win32; using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Principal; public static class UacHelper { private const string uacRegistryKey = “Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System”; private const string uacRegistryValue = “EnableLUA”; private static uint STANDARD_RIGHTS_READ = 0x00020000; private static uint TOKEN_QUERY = 0x0008; private static uint TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY); [DllImport(“advapi32.dll”, SetLastError = true)] [return: … Read more

How do I disable the ‘Debug / Close Application’ dialog on Windows Vista?

To force Windows Error Reporting (WER) to take a crash dump and close the app, instead of prompting you to debug the program, you can set these registry entries: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting] “ForceQueue”=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent] “DefaultConsent”=dword:00000001 After this is set, when your apps crash, you should see *.hdmp and … Read more

Windows batch file starting directory when ‘run as admin’

Try to access the batch files path like this: echo %~dp0 For more information see the following quote from the command for /? that describes how the above command works: You can now use the following optional syntax: %~I – expands %I removing any surrounding quotes (“) %~fI – expands %I to a fully qualified … Read more

Request UAC elevation from within a Python script?

As of 2017, an easy method to achieve this is the following: import ctypes, sys def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if is_admin(): # Code of your program here else: # Re-run the program with admin rights ctypes.windll.shell32.ShellExecuteW(None, “runas”, sys.executable, ” “.join(sys.argv), None, 1) If you are using Python 2.x, then you should … Read more

eclipse stuck when building workspace

I was able to fix this with the following: First, exit Eclipse. Then temporarily move the following .projects folder to a safe location: mv .metadata\.plugins\org.eclipse.core.resources\.projects projects Start and exit Eclipse, then move the .projects folder back to where it was originally: mv projects .metadata\.plugins\org.eclipse.core.resources\.projects Use at your own risk, of course.

IIS does not list a website that matches the launch url

I hate answering my questions: in my question i stated that i was running VS under the administrator account. This was not true!!! So the solution (for me) was to run VS2010 as administrator (Start->In Vista menu right click-> Run as administrator)…so simple. As a side effect: VS2010 let me also create Virtual Directories without … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)