Guys, how do I run a script in the Execute Command node with admin permission? I use the Desktop version. I’ve already tried to put cmd and windows powershell in this mode by default, but without success.
I’ve been trying to resolve this for two days. I’ve already put it for windows powershell to boot as administrator…
Hey @Guilherme_Hirsch, you could include the admin part in your script rather than in n8n, so you wouldn’t need to elevate n8n’s permissions.
E.g. have your Execute Command node call a script using
Then in the
test.ps1 script itself, you could request admin permissions like so for the command that needs them:
Start-Process -Verb RunAs pwsh.exe -Args '-executionpolicy bypass -command "echo foo"'.
In my case it is a python file. Do I include this permission request in the node field? Thanks a lot for the help, @MutedJam!
I don’t think the Execute Command node can run cmdlets directly which would be required to start a process with elevated privileges. So you might need to create a Powershell script to launch your Python script (simply replace the
echo foo part from my previous example with your python command - you might need to use backslashes and a full path though when using Windows).
Keep however in mind there is usually little value over simply manually running your Python script requiring admin privileges though. That’s because Windows will display the User Account Control dialog (“Do you want to allow this app to make changes to your device?”) asking for admin permissions every time you run it. So even with n8n this would require manual user interaction.
Edit: If this is a local script of yours, is there a chance you can adjust it so it no longer needs admin permissions? This would make things a lot easier (and safer).
Yes, it’s a local script, @MutedJam.
Basically I want to do the following
I included the following script in the node field:
Start-Process -Verb RunAs powershell.exe -Args '–ExecutionPolicy Bypass -command “python códigos\arquivos_xml.py”'
But it didn’t work.
Hi @Guilherme_Hirsch, could you try wrapping this command in a Powershell script and then call your Powershell script from the Execute Command node instead? I don’t think the node is able run Powershell cmdlets like Start-Process directly.
In Execute Command you can run PowerShell “Get-AdComputer” and it will execute this I have tested with the Desktop version on Windows.