4

I am trying to install Notepad++ software using a PowerShell v2.0 script for one of my POC. I need to install the client's software in my current project. As I am running the below script I'm getting errors.

Start-Process 'C:\Users\kirnen\Desktop\A\npp.7.5.Installer.exe'-InstallerParameters "/S" `
-RegistryKey HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Notepad++ `
-RegistryName DisplayVersion -RegistryValue 7.5

As I am very much new to powershell scripting, can you please help in this? Is the above code right, or do I need to change anything else to install the software?

2
  • 3
    There is no parameter like -RegistryKey or InstallerParameters for Start-process. The Notepad exe should write such regkeys. Try google to find how to install an exe with powershell Commented Aug 18, 2017 at 12:42
  • can you help in this. wat I need to do..?? Commented Aug 18, 2017 at 12:45

5 Answers 5

4

I use this snippet of PowerShell code for a lot of installs. As long as you can figure out the silent switch for ".exe's". For ".msi's" just change out where Create() with Create("msiexec /I C:\temp\generic.msi /qn")

$computers = c:\temp\computerName.csv
$Notepad = "Location of notepad install"

$computers | where{test-connection $_ -quiet -count 1} | ForEach-Object {

  copy-item $Notepad -recurse "\\$_\c$\temp" 

  $newProc=([WMICLASS]"\\$_\root\cimv2:win32_Process").Create("C:\temp\npp.6.9.2.Installer.exe /S")

  If ($newProc.ReturnValue -eq 0) { 
    Write-Host $_ $newProc.ProcessId 
  } else { 
    write-host $_ Process create failed with $newProc.ReturnValue 
  }
}
Sign up to request clarification or add additional context in comments.

Comments

3

There are a few different ways to do this. The way you're doing it is fine, but I don't think you really want all those install parameters.

Start-Process 'C:\Users\kirnen\Desktop\A\npp.7.5.Installer.exe' "/S"

The /S part means you want a silent install, so you won't see an install wizard, and won't be able to choose any options. Not a bad thing, just be sure that's what you want. Take off the "/S" if you want to follow the graphical install wizard.

Instead of Start-Process you can also use cmd /c and just &. These have their advantages and disadvantages. Stick with Start-Process for now.

One last thing, with many .exe files you can follow them with /help or /? to get a list of their command line switches.

Comments

2

#Install Chocolatey Provider

Get-Package -Provider chocolatey -Force

#Install Software

Install-Package adobereader, 7zip, anydesk, firefox, notepadplusplus, teamviewer, vlc -Force

Comments

0

Try to use the Winget utility

Do Winget search "YourPackage" on cmd or powershell terminal and take what package you want and do "Winget install YourPackage" Like this for example i want to install chrome :

Winget install Google.Chrome

Comments

0

I created a Powershell script with Chocolatey to perform the installation of programs from a list in json.

It will install chocolatey, check the packages, and them install it

Take a look in the repo: https://github.com/SandimL/Powershell-automatic-installation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.