Skip to content
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 Admin #417

Open
matthiscock opened this issue Nov 18, 2024 · 1 comment
Open

Run As Admin #417

matthiscock opened this issue Nov 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@matthiscock
Copy link

What were you trying to do?

Running a shell_exec (or better way) as Admin
This is to allow it to run a powershell command as admin

(PS This is a local app, which is designed to interact with the local filesystem, I understand the risks on the security side)

What happened?

No way to elevate in Native PHP the command.
Im probably doing it wrong or using the wrong way of doing it, apologies if I am

How to reproduce the bug

$output = shell_exec('powershell -verb runas "New-Item /somewhere.protected/' . $name . ' -Value "' . $template . '""');

ERror comes back saying not enough permission

Package Versions

latest

PHP Version

8.20

Laravel Version

11

Node Version

22

Which operating systems have you seen this occur on?

Windows

OS version

Win 11

Notes

Im pretty sure im running this wrong, I know there are electron ways, but im a complete newbie and just getting to grips with it all.
Any help or advice is greatfully taken!

Thanks

@matthiscock matthiscock added the bug Something isn't working label Nov 18, 2024
@simonhamp
Copy link
Member

My understanding is that you won't/shouldn't be able to elevate permissions like this as that would end up being a massive security hole.

The user will explicitly need to start the app as the administrator when opening it.

I'm not sure if this is still possible on Windows, but it used to be a thing where you could right-click on the icon and select 'Run as Administrator'.

Maybe this will pass that permission down into any shell_exec calls you then make inside the app 🤷🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants