1.    14 Sep 2015 #1
    Join Date : Sep 2015
    Posts : 4
    Win10

    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.    14 Sep 2015 #2
    Join Date : Jul 2014
    San Jose, California
    Posts : 2,193
    Ubuntu14.04x64 MintMate17x64 Win10Prox64

    How about using: echo "Hello" & pause
      My ComputerSystem Spec
  3.    14 Sep 2015 #3
    Join Date : Sep 2015
    Posts : 4
    Win10
    Thread Starter

    Quote Originally Posted by topgundcp 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.    14 Sep 2015 #4
    Join Date : Aug 2015
    Spring Valley
    Posts : 559
    Windows 10 Pro/Windows 7 Ultimate

    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
    Join Date : Sep 2015
    Posts : 4
    Win10
    Thread Starter

    Quote Originally Posted by XweAponX 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
    Join Date : Sep 2015
    Posts : 4
    Win10
    Thread Starter

    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\foobar\
    D:\foo\bar\foo bar\
    D:\@foo\bar\foobar\
    D:\@foo\bar@\foobar\

    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.

    Weird.
    I'd love to hear an explanation, if anyone has one :-)
      My ComputerSystem Spec
  7.    3 Weeks Ago #7
    Join Date : Jun 2016
    Posts : 5
    Windows 10 Pro

    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
    pause

    Additional suggestions, or ideas welcome.
      My ComputerSystem Spec
  8.    3 Weeks Ago #8
    Join Date : Jan 2015
    UK, Midlands
    Posts : 11,108
    Win 10 Pro (1703)

    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
    Shellexview
    Shellmenu
    (free)

    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.    3 Weeks Ago #9
    Join Date : Jun 2016
    Posts : 5
    Windows 10 Pro

    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.    1 Week Ago #10
    Join Date : Nov 2017
    Posts : 1
    win10pro/win10home

    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

 


Similar Threads
Thread Forum
Solved Optimization not available suddenly on SSD
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...
Performance & Maintenance
Solved How to Add "Run as administrator" to Context Menu of MSI Files in W10
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...
Software and Apps
Windows 10 - Suddenly Crashing On Startup
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...
Performance & Maintenance
Suddenly Going back to W7 while Installing W10
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...
Installation and Upgrade
Solved What the...??? Suddenly Palemoon has gone borderless...
...and completely unusable...
General Support
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 00:01.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums