Location:
State:
Carrier
Country
Status

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

How about using: echo "Hello" & pause

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.

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.

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.

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:fooarfoobar
D:fooarfoo bar
D:@fooarfoobar
D:@fooar@foobar

But these prevent the target (batch file) from running:
D:@fooarfoo bar
D:fooar@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 :-)

Suddenly can't run bat files as administrator