windows 7 - Why is the "Run as Administrator" checkbox disabled?

06
2014-04
  • Nam G. VU

    I have a .bat file that cannot allow me to set it to run as admin as required by going to the Properties box and check for Privilege checkbox.

    But mine is disabled as below snapshot.

    What can I do to get it enabled?

    enter image description here

  • Answers
  • Oliver Salzburg

    It doesn't work because it's a batch file.

    I like to use the following approach to get around this limitation:

    @if (1==1) @if(1==0) @ELSE
    @echo off&SETLOCAL ENABLEEXTENSIONS
    >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||(
        cscript //E:JScript //nologo "%~f0"
        @goto :EOF
    )
    echo.Setting IP configuration to DHCP...
    netsh interface ipv4 set address "Local Area Connection" dhcp
    echo.Setting DNS configuration to DHCP...
    netsh interface ipv4 set dnsservers "Local Area Connection" dhcp
    pause
    @goto :EOF
    @end @ELSE
    ShA=new ActiveXObject("Shell.Application")
    ShA.ShellExecute("cmd.exe","/c \""+WScript.ScriptFullName+"\"","","runas",5);
    @end
    

    This would enable DHCP for a network adapter. Should be fairly easy to adjust to your needs.

  • Rudolph

    I think I've got the solution for you. You need to turn off UAC and back on again:

    How to turn UAC on or off

    Open User Account Control Settings by going to Start > Control Panel. In the search box, type "uac" without quotes, and then click Change User Account Control settings.

    Do the following:

    1. Turn off UAC - move the slider to the Never notify position, and then click OK. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation. You will need to restart your computer for UAC to be turned off.

    2. Turn on UAC - move the slider to choose when you want to be notified, and then click OK. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

    Way back I dealt with a similar issue on an .exe file and I recall trying this after some research over here. It solved my problem right away.


  • Related Question

    windows 7 - Drag and Drop File into Application under run as administrator
  • Chris Dwyer

    Whenever I have an application running (Visual Studio 2008, Notepad, etc.) under "Run as Administrator", I cannot drag and drop files from Windows Explorer into the application.

    I've tried running Windows Explorer as administrator, but to no avail.

    Is there a way to get drag and drop to work when my applications are under "Run as Administrator"?


  • Related Answers
  • A Dwarf

    The problem is tied to how security permissions work. The ability to drag and drop from a normal applications to an elevated one would break the security model behind UAC. However, I'm unclear as to why a UAC prompt isn't shown, thus allowing for a temporary elevated operation (much like any linux user experiences every day). This is definitely something that Microsoft needs to work on. What troubles me is that this problem is already old. Vista behaved the same.

    There's 2 things you can do (one ugly, one annoying)

    • Ugly: Disable UAC. But you lose all the extra security it offers.
    • Annoying: Use another File manager and run it too as an Administrator

    Why another file manager? Because you can't actually elevate Windows Explorer. Despite seeing the option in the context menu of the Windows Explorer icon and a UAC prompt being displayed, the fact is Windows Explorer will not be elevated.

  • Salar Khalilzadeh

    This is a workaround according to ADwarf "Annoying" solution: open Notepad with "Run as Administrator". Click on open in file menu and enter * in file name and press enter. Now you can drag files from there to your app. Notepad open browser doesn't support multiply file selection, but you can use other programs in the same way to use drag and drop!

  • John M. Black

    There was an update to Visual Studio 2005 published 2 years ago that fixed many UAC problems on Vista, and that same update fixes the same problems on Windows 7.

    It is not a critical update so you wouldn’t get it automatically, and it was not included with VS2005 SP1. They’re not actively publicizing this update now b/c they just want everyone to go to VS2008. So chances are you don't have it.

    Explanation at http://msdn.microsoft.com/en-us/vstudio/aa948853.aspx?lcid=1033

    Download at http://www.microsoft.com/downloads/details.aspx?FamilyID=90e2942d-3ad1-4873-a2ee-4acc0aace5b6&displaylang=en

    Here's what that update fixes, when running Visual Studio in normal user mode with UAC turned on:

    • Drag/drop files from an explorer window
    • Launching VS (as a normal user) by launching shortcuts to solutions/projects or associated file types
    • DLL/EXE registrations still fail (rightly so, since those are system-level changes.)

    If you're running VS as an administrator, the window is still locked down to drag/drop and shortcuts, and DLL/EXE registrations work correctly without having to completely turn off UAC.

    Note: VS will still warn you about administrator mode when you launch it, but now you can probably ignore that warning permanently.

  • Community

    Windows 7:

    Launch PowerShell using Run As Administrator

    Type:

    taskkill /f /im explorer.exe

    start-process explorer.exe

    or launch cmd (Command Prompt) using Run As Administrator

    Type:

    taskkill /f /im explorer.exe

    start explorer.exe

    All your new Explorer windows will now be elevated and you can drag and drop from them into other elevated applications. I tested and verified this prior to posting.