Install exe file using powershell

Hi guys,
I’ve create the script to download an exe file then install the software. Here is my script:

$path = 'c:\test\wiztree_4_01_setup.exe'
$arg = '/install', '/quiet', '/norestart'
Invoke-WebRequest -Uri 'https://diskanalyzer.com/files/wiztree_4_01_setup.exe' -OutFile $path
Start-Process -FilePath $path -ArgumentList $arg -Wait
Start-Sleep -s 2

However when running the script, the installation window pop up, waiting for me to hit install. How to install it without manual click to install? Thanks for your time.

Silent install is normally the exe’s feature. Here I thing its because of the way the $arg is constructed.

make $arg = '/install /quiet /norestart', otherwise its treated as array and think exe cannot understand it.

Hi Kvprasoon,
Thank you and I appreciated your time. I’ve tried to change the $arg as per your suggestion, but the pop up window still appear. So, I will have to click on install, accept license agreement…etc.

You need to check the exe’s specific syntax/supported switches/documentation. Each exe can choose their own parameters/arguments. Many share similar options but only the specific exe and what it supports are what you need to look at to determine what (if any) arguments provide silent install. Also be aware not every exe even offers silent install.

Avoid installing and use the portable version :partying_face:

$path = 'E:\Temp\Files\wiztree_4_01_portable.zip'
Invoke-WebRequest -Uri 'https://diskanalyzer.com/files/wiztree_4_01_portable.zip' -OutFile $path
Expand-Archive -Path $path -DestinationPath E:\Temp\Files\WizTree

Thanks Matt,
Agreed totally with you. The main purpose of my script is to test how to install the exe file using powershell.

Since PowerShell is a command line shell there’s not that much difference between PowerShell and CMD for example.

Most installer executables reveal their possible command line arguments when you call them with the option /?.
So if the command line

c:\test\wiztree_4_01_setup.exe /?

reveals that the proper command line arguments for the installer are /install, /quiet and /norestart you can run the installation just like in CMD with

c:\test\wiztree_4_01_setup.exe /install /quiet /norestart
1 Like

Hi Olaf,
Big thank you for your tip. I have corrected the arguments and have tested to install the exe file via a remote session. It works fine. Below is the working script:

<#How to get arguments.In this example: Run C:\test\wiztree_4_01_setup.exe /?
To use local variable for remote session, use: $Using:<variable name> #>
$computers = $env:COMPUTERNAME
$cmd = 'C:\test\wiztree_4_01_setup.exe'
$prm = '/SILENT','/SP','c:\test\wiztree_4_01_setup.exe','AGREETOLICENSE=Yes','LANG=English'
$session = (New-PSSession -ComputerName $computers)
Invoke-Command -Session $session -ScriptBlock {
Invoke-WebRequest -Uri 'https://diskanalyzer.com/files/wiztree_4_01_setup.exe' -OutFile $Using:cmd
Start-Process -FilePath $Using:cmd -ArgumentList $Using:prm
Start-Sleep -s 2}

Kind Regards,
Son

2 Likes