Open matthiscock opened 22 hours ago
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 🤷🏼
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