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

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

How do you clear your Visual Studio cache on Windows Vista?

The accepted answer gave two locations: here C:\Documents and Settings\Administrator\Local Settings\Temp\VWDWebCache and possibly here C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\WebsiteCache Did you try those? Edited to add On my Windows Vista machine, it’s located in %Temp%\VWDWebCache and in %LocalAppData%\Microsoft\WebsiteCache From your additional information (regarding team edition) this comes from Clear Client TFS Cache: Clear Client TFS … 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

Launching an application (.EXE) from C#?

Here’s a snippet of helpful code: using System.Diagnostics; // Prepare the process to run ProcessStartInfo start = new ProcessStartInfo(); // Enter in the command line arguments, everything you would enter after the executable name itself start.Arguments = arguments; // Enter the executable to run, including the complete path start.FileName = ExeName; // Do you want … Read more

Maximum filename length in NTFS (Windows XP and Windows Vista)?

Individual components of a filename (i.e. each subdirectory along the path, and the final filename) are limited to 255 characters, and the total path length is limited to approximately 32,000 characters. However, on Windows, you can’t exceed MAX_PATH value (259 characters for files, 248 for folders). See http://msdn.microsoft.com/en-us/library/aa365247.aspx for full details.

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