

But when the UAC setting is at a lower level, signed Windows EXEs are elevated silently. So, admittedly my method isn't perfect since it can be broken, but it's a relatively quick method that's easy to implement, is equally compatible with all versions of Windows 7, 8 and 10, and provided I stay mindful of the mentioned caveats has been 100% effective for me.RECOMMENDED: Click here to fix Windows issues and optimize system performanceĮver since Windows Vista introduced User Account Control, there has been a need to occasionally run some programs as administrator for doing some functions. If the UAC setting is set to the highest level in Windows, then you get a UAC prompt when you open an app as administrator. If for any reason the user MUST be able to access the WDI folder with Windows Explorer, then you'd have to modify the code to check a different folder (as mentioned above, creating your own specifically for this purpose may be a good choice). If this happens, it can be fixed by removing the user account from the WDI folder security permissions. There are two caveats about this method though:ĭisabling UAC will likely break it through the simple fact that everything would be run as admin anyway.Īttempting to open the WDI folder in Windows Explorer and then clicking "Continue" when prompted will add permanent access rights for that user account, thus breaking my method. Even in that case, it's simply a matter of modifying the code to check for a different common file/folder that requires admin access (System32\config\SAM may be a good alternate candidate), or you could even create your own specifically for that purpose.


Keep in mind that this method assumes the default security permissions have not been modified on the WDI folder (which is unlikely to happen in most situations, but please see caveat #2 below). (Commands for running with admin privileges) (Commands for running with normal privileges) Here's a brief snippet of example code: IF EXIST %SYSTEMROOT%\SYSTEM32\WDI\LOGFILES GOTO GOTADMIN This can be used in a batch file to check privilege level, and branch to whichever commands you desire based on that result. So, running "IF EXIST" on the WDI\LogFiles folder will return true if run as admin, and false if not run as admin. The WDI folder always has a LogFiles folder inside it. The WDI folder exists on every install of Windows from at least 7 onward, and it requires admin privileges to access. Basically, I simply use the "IF EXIST" command to check for the Windows\System32\WDI\LogFiles folder. Here's a simple method I've used on Windows 7 through Windows 10.
