Windows 10: Suddenly can't run bat files as administrator

  1.    14 Sep 2015 #1

    Suddenly can't run bat files as administrator

    New, weird, behavior --

    If I right click on a bat file, and Run as Administrator, all I get is a brief flash (perhaps a command window?).
    Just double clicking on it runs as expected (though not elevated, which is what I need).
    If I open an elevated command window and run the bat file within that window it works fine.

    So I have a workaround, but it's still annoying.
    It's always worked as expected in the past, I last used the batch files about a week ago.

    Tested with a simple bat file (echo "hello", pause). Same results.

    The fact that it is only a problem when I try Run as Administrator has me baffled.

    WIn10 Home build 10240, administrator user account
      My ComputerSystem Spec

  2. topgundcp's Avatar
    Posts : 2,438
    Ubuntu14.04x64 MintMate17x64 Win10Prox64
       14 Sep 2015 #2

    How about using: echo "Hello" & pause
      My ComputerSystem Spec

  3.    14 Sep 2015 #3

    topgundcp said: View Post
    How about using: echo "Hello" & pause
    Thanks, but that's irrelevant. I was just indicating that I had duplicated the problem with a simple batch file. (It actually had the commands on two lines).

    The contents of the batch file don't matter, the issue is that the "Run as Administrator" menu popup in Explorer no longer works properly.
      My ComputerSystem Spec

  4. XweAponX's Avatar
    Posts : 561
    Windows 10 Pro/Windows 7 Ultimate
       14 Sep 2015 #4

    Are you right-clicking on the file and running it "as administrator"? Because with Bat files, you should open a Command Prompt (Admin) By pressing Windows key+X, then after it is open, CD to the folder where the BAT files are, and then run it. That way, you can see if it ran or if it failed.
      My ComputerSystem Spec

  5.    14 Sep 2015 #5

    XweAponX said: View Post
    Are you right-clicking on the file and running it "as administrator"? Because with Bat files, you should open a Command Prompt (Admin) By pressing Windows key+X, then after it is open, CD to the folder where the BAT files are, and then run it. That way, you can see if it ran or if it failed.
    Opening an elevated command prompt, as you describe, and as I mentioned, does work.
    Right-click, Run as Administrator no longer works. It used to.
    Running non-elevated, either by double-clicking or via opening a command prompt works (though then various commands fail due to lack of permission, as expected.)

    The weird thing is that right-click, Run as Administrator stopped working.
      My ComputerSystem Spec

  6.    14 Sep 2015 #6

    Well, I think I've got it, and it's definitely one of the more bizarre Microsoft bugs I've run into:

    The right-click, Run As Administrator function in File Explorer fails if the path to the target contains both an at sign (@) and a space.

    For example these paths work:
    D:\foo\bar\foo bar\

    But these prevent the target (batch file) from running:
    D:\@foo\bar\foo bar\
    D:\foo\bar\@foo bar\

    Or perhaps the actual bug is slightly different, but from the limited testing I performed, it's only the specific combination of @ and space, somewhere in the path, that causes failure. Other (non-reserved) special characters and unicode characters seem to work just fine.

    I'd love to hear an explanation, if anyone has one
      My ComputerSystem Spec

  7. Posts : 6
    Windows 10 Pro
       15 Nov 2017 #7

    Came across the exact same problem as CapnM on Windows 10 Pro 64-bit, where batch file does not "Run as Administrator" upon a right-click, but does from an elevated command prompt. But I don't think his suggestion applies to this .bat script that deletes OneDrive:

    taskkill /f /im OneDrive.exe
    %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
    rd "%UserProfile%\OneDrive" /Q /S
    rd "%LocalAppData%\Microsoft\OneDrive" /Q /S
    rd "%ProgramData%\Microsoft OneDrive" /Q /S
    rd "C:\OneDriveTemp" /Q /S
    REG Delete "HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f
    REG Delete "HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" /f

    Additional suggestions, or ideas welcome.
      My ComputerSystem Spec

  8.    16 Nov 2017 #8

    Hi, does 'Run as admin' work on anything?

    Users who have had problems with this have found there's another shell extension present, which, when disabled, magically allows Run as admin to work again.

    Try disabling other (non-MS) context menu entries using

    Remember to make sure MS entries are hidden in Options (they should be by default) as disabling them can cause difficulty.

    Two recent examples were
    winrar and something like quicksfv
      My ComputerSystem Spec

  9. Posts : 6
    Windows 10 Pro
       16 Nov 2017 #9

    I got my old scripts to work. I moved them to the root level directory on C:\ All is back to normal.
      My ComputerSystem Spec

  10. Posts : 1
       29 Nov 2017 #10

    This was my experience too...

    Same as above . . . I tried to Run As Administrator from context menu on a bat file. (not a cmd file). Did not work when the file was on the desktop, just a dialog flash and disappear as op said. Moved file to root of c:, ran same command same way, worked fine. Anyone have any ideas or answers? Permissions issue? Running Win10Home x64
      My ComputerSystem Spec


Related Threads
Solved Optimization not available suddenly on SSD in Performance & Maintenance
Hi, I have a strange problem. Suddenly optimization is not available for my SSD partitions in the Win 10 defrag tool. Before you say defrag is not done on SSD let me say that I checked and the Win 10 tool auto detects its SSD and preforms TRIM...
Run as administrator - Add to MSI File Context Menu - Windows 7 Help Forums Is this still applicable for windows 10? I have not yet attempted to do this. In my Downloads folder there are right click options to Install / Repair / Uninstall...
Windows 10 - Suddenly Crashing On Startup in Performance & Maintenance
Hi all, I have started experiencing some problems over the last few days in relation to the startup of Windows 10. I'm not overly sure why, but recently when I have been starting the computer for the first time in any given day, the wheel that...
I was installing W10 and got that black screen with the big white circle. Then, once it restarted. When it booted again, suddenly a screen came up saying "Attempting to Recover Installation" then saying "Restoring your previous version of...
...and completely unusable...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 02:15.
Find Us