-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run as Administrator Bug #1
Comments
Which Windows version? What happens when you run I'll try to find a better way to check for Administrator privileges. The current method is admittedly a bit of a hack. |
Requires powershell to be installed, but this will have the script elevate itself. set script=%~f0
@powershell -command "Start-Process cmd.exe -ArgumentList \"/C %script%\"" -verb RunAs |
mpv dropped XP support and powershell is bundled with vista+ so this should be fine. |
Windows 7. With regards to power shell: since I am not conversant with its command line parameters and functions and furthermore no instructions were given to actually use that as an alternative, then I cannot see how I was supposed to know that I could use it for its better powers. |
I was speaking to rossy. |
I answered rossy and wrote a comment on your comments because after all |
This might be more reliable, since apparently there are situations where `net session` doesn't work. Could help with #1.
Well, I changed ensure_admin to do something slightly different. @brandleesee, could you test it on your system? @Link-Satonaka, I originally avoided using PowerShell to elevate because I would have to test with all PowerShell versions and the logic wouldn't be easy, for example, if it failed to elevate, I didn't want it to get caught in an infinite loop. It's definitely a possibility if I can get that stuff figured out, though. I'll have a look at it. |
@rossy Worked perfectly, cheers! |
Thanks for testing! |
In case anyone ever have the need and is reading this, here's another "check for admin rights" method:
Seems to work as intended, but not sure how far it goes regarding Windows versions. (from "Burf's Visual C++ Redist Installer" .bat file). |
@garoto That's actually pretty neat. It seems to work because S-1-5-19 is the well known SID for the LOCAL SERVICE user, hence the key always exists and it's never readable by non-admins. It also has no dependencies other than reg.exe, which this script needs anyway. I might go for that method if/when the openfiles.exe method breaks. |
Glad you found it useful rossy. And thanks for explaining what that regkey actually means/does. I had no clue :) |
Despite Right Clicking and Run-ning as Administrator, the dialog kept instructing me to actually right click and click on "Run as Administrator".
Work around:
Right click on .bat file, and remove the following code:
:: Make sure the script is running as admin
call :ensure_admin
Once the above step was done, the script worked perfectly.
The text was updated successfully, but these errors were encountered: