Hello team, could you please help me with this small issue?
I am automating the silent installation of Pritunl via PowerShell. I have used this article. When using the install attributes: â/VERYSILENT EULA_ACCEPT=YESâ or â/VERYSILENTâ or â/VERYSILENT /SUPPRESSMSGBOXESâ or â/QUIET /VERYSILENTâ the installation returns with the error code 1 and description âincorrect functionâ.
Where seems to be the issue?
The way I am getting the error code is by this ps script ran as admin:
$URL = 'https://github.com/pritunl/pritunl-client-electron/releases/download/1.3.3281.66/Pritunl.exe'; <#Insert download URL#>
$File = "Pritunl.exe"; <#Insert the name of downloaded file#>
$Folder = "Pritunl"; <#Insert folder name to contain the downloaded file#>
$FolderPath = "$env:TEMP\$Folder"; <#Insert root folder path for the above folder followerd by \$Folder#>
$FilePath = "$FolderPath\$File"; <#File path for the downloaded file#>
$InstallArguments = '/VERYSILENT EULA_ACCEPT=YES'; <#Insert install arguments#>
function CleanWorkDirectory {
if <#f1.0#>(Test-Path -Path $FolderPath)<#Directory found#>
{
Write-Host "Cleaning download directory $Folder, please wait ...";
Remove-Item -Path $FolderPath -Recurse -Force -Confirm:$false;
Start-Sleep -Milliseconds 50;
if <#f1.1#>(Test-Path -Path $FolderPath)
{
Write-Host "Directory $FolderPath could not be removed by the script.`nPlease try removing it manually.`nThe folder is located in $FolderPath.";
}
else <#f1.1#><#File deleted successfully#>
{
Write-Host "The directory $Folder was removed from the system.";
}
}
else <#f1.0#><#Directory not found#>
{
Write-Host "Directory `"$FolderPath`" was either not found or deleted in other methods.`nProceeding to the next step `(if any`).";
}
}
New-Item -Path $env:TEMP -Name $Folder -ItemType "directory" -Force | Out-Null;
Write-Host "Created download directory with the path $FolderPath.`nDownloading $File, please wait ...";
$Download = New-Object System.Net.WebClient;
$Download.DownloadFile("$URL","$FilePath");
if <#1#>(Test-Path -Path $FilePath -PathType Leaf) <#Download is successful#>
{
Write-Host "File $File finished downloading, proceeding to installation.";
$Install = Start-Process -FilePath $FilePath -ArgumentList $InstallArguments -PassThru -Wait;
if <#2#>($Install.ExitCode -eq 0) <#Installation is successful#>
{
Write-Host "Exit code received $($Install.ExitCode), Installation was succesful." -ForegroundColor Yellow -BackgroundColor DarkGray;
Start-Sleep -Seconds 1;
CleanWorkDirectory;
}
else <#2#><#Installation failed#>
{
Write-Host "Installation of $File failed. Error described is:";
Write-Host $Install.ExitCode -ForegroundColor Yellow -BackgroundColor DarkGray;
net helpmsg $Install.ExitCode;
CleanWorkDirectory;
}
}
else <#1#><#Download failed#>
{
Write-Host "The files $File did not download, process will terminate without installation.`nDeleting work directory $FolderPath.";
Remove-Item -Path $FolderPath -Recurse -Force -Confirm:$false;
}
Start-Sleep -Milliseconds 50;
Normally I believe that only 0 is considered success, while every other return code than 0 means it returned an error. Although, despite the error âIncorrect Functionâ, the application does get installed, but only sometimes.
Tried using win10 and win11 physical and vm environments.