Force a command without UAC elevation in PowerShell

  • Post category:IT
  • Post comments:0 commentaire
  • Post last modified:12 juin 2021
  • Temps de lecture :2 min de lecture

The version of Darktable in the scoop extras bucket was very old, because of the new exe file distribution. I wanted to improve that. One of the biggest problem was to get rid of the UAC elevation asked by the NSIS installation script, which was quite useless with the use of another folder than the default one.

A google search gives as a result that you can force no UAC elevation with RunAsInvoker. Under cmd.exe it would be :

As scoop run in PowerShell, here is the PowerShell version  :

In the scoop script, another difficulty is to get the proper variable substitution. To do so, you will need to use Invoke-Expression :

Doing so it won’t wait for the installation to be done. A simple way to wait for completion is to add a pipe to Out-Null. Indeed, with a pipe, it will force PowerShell to wait the end of the first process! So the final string, with proper quote escaping is :


References :

Laisser un commentaire

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.