4

I've been trying to install Notepad++ version 7.5.6 on numerous remote servers completely unattended. I've researched and found the silent switch '/S' but it doesn't work as I intended in my local environment. When I run the following code, it still generates a popup for the language, just as if I had clicked on the installer manually.

start-process -FilePath "$Path\npp.7.5.6.Installer.x64.exe" -ArgumentList '/S' -wait

As far as I can tell, this shouldn't produce any popups, but it does, starting with the User Account Control.

Can anyone figure out what I'm doing wrong and how to get the installer to run completely unattended without any popups?

CuriousOne
  • 922
  • 1
  • 10
  • 26
  • Simply because I don't know enough about msi and I already had the exe – CuriousOne May 10 '18 at 14:13
  • 3
    You need to run PowerShell elevated if you want to avoid the UAC and `-Verb RunAs` on `Start-Process` – Maximilian Burszley May 10 '18 at 14:14
  • If process starting installer is not already elevated, you can't bypass the UAC prompt. This is by design. – Bill_Stewart May 10 '18 at 14:15
  • You might consider using [psexec](https://learn.microsoft.com/en-us/sysinternals/downloads/psexec) for this. – langstrom May 10 '18 at 14:19
  • I can't use psexec in my environment, also WinRM isn't configured, so that's a whole other can of worms. The problem I was having is with the elevated session. I can now get it to work locally. Thanks – CuriousOne May 10 '18 at 14:55

2 Answers2

4

As @TheIncorrigible1 said you need to use -Verb runas

start-process -FilePath "$Path\npp.7.5.6.Installer.x64.exe" -ArgumentList '/S' -Verb runas -Wait
Bonneau21
  • 544
  • 1
  • 5
  • 20
2

Adding a bit more to the original answer.

I wanted the latest version to be installed everytime so I ended up doing this with a PowerShell script:

$LocalTempDir = $env:TEMP
$href = ((Invoke-WebRequest -Uri 'https://notepad-plus-plus.org/downloads/').Links | Where-Object { $_.innerText -match 'current version' }).href
$downloadUrl = ((Invoke-WebRequest "https://notepad-plus-plus.org/$href").Links | Where-Object { $_.innerHTML -match 'installer' -and $_.href -match 'x64.exe' }).href
Invoke-RestMethod $downloadUrl -OutFile "$LocalTempDir/np++.exe"
start-process -FilePath "$LocalTempDir\np++.exe" -ArgumentList '/S' -Verb runas -Wait
Peroxy
  • 646
  • 8
  • 18
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30032065) – Peacepieceonepiece Oct 09 '21 at 12:39
  • Thanks, very useful script! Exactly what I need – Peroxy Nov 10 '21 at 09:46