Run As a administrator script

Most domain admins these days are following the very smart practice of using a normal user account for their day to day work and another for their domain admin tasks. Usually it is the same username with da at the end, beginning or something similar. The trouble comes in when a admin wants to use something like an MMC app like dhcp, dns domain users and computers etc. each time you are forced to right click and open as another user etc etc. This becomes very tedious!! Well I have a couple easy solutions for this. how about opening up one explorer window with your domain admin credentials then all apps that you open from that explorer window are run using those credentials! that would be great right make life easier right? Well here is how you do it.

I personally prefer to use windows explorer but Microsoft locks down explorer so you have to hack the registry to be able to run it as a different user in windows 7 and newer operating systems. If you want to get around this follow these steps

  1. Start -> Run -> regedit
  2. Navigate to the registry key: HKEY_CLASSES_ROOT\AppID{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}
  3. Right click on the registry key and click Permissions…
  4. Give Full Control permissions to the user logged in.
  5. Start -> Run -> dcomcnfg.exe -> Expand DCOM Config
  6. Right click and select properties of “Elevated-Unelevated Explorer Factory”, click the Identity tab and select “The launching user”

After doing this explorer.exe will launch as the user specified in the RunAs.exe command!

I personally prefer to use an open source file explorer called explorer++ you can download it from here https://explorerplusplus.com/

I will give the scripts to work for both file explorer options.

first method batch file:

The batch file method will prompt for a password in a dos box but it works just fine
Explorer ++

@echo off
runas /user:domain\%username%DA C:\explorer++\explorer++.exe

Windows Explorer

@echo off
runas /user:domain\%username%DA C:\%windir%\explorer.exe

PowerShell Method:

The powershell method will pop up a windows login box for entering your password for authentication.

Windows Explorer

Set-ItemProperty ‘HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds’ ConsolePrompting $true
$adDom = “DOMAIN\”

#Get “friendly” UserName
$uName = [Environment]::UserName

#Prompt for password
$UserName = $adDom + $uName
$UserCred = Get-Credential $UserName

#Spawn instance using new account
Start-Process –cred $UserCred C:\%windir%\explorer.exe

Explorer++

Set-ItemProperty ‘HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds’ ConsolePrompting $true
$adDom = “DOMAIN\”

#Get “friendly” UserName
$uName = [Environment]::UserName

#Prompt for password
$UserName = $adDom + $uName
$UserCred = Get-Credential $UserName

#Spawn instance using new account
Start-Process –cred $UserCred C:\explorer++\explorer++.exe