TW-CJ
TW-CJ

Reputation: 11

Powershell script to silently download from URL

I am creating a script that will check if a file is in the downloads folder, silently install if found or silently download if not found.

Steps:

  1. Look in the downloads folder for the .exe file
  2. Silently install the .exe file if found
  3. Silently download the .exe file from a URL if not found, then silently install

I am not sure how to silently perform the above, I keep getting a window that pops up showing the download. Here is my script, I am a beginner with PS so go easy on me

if ( Get-ChildItem -Path C:\Users\*\Downloads\7z1900.exe )
{
    7z1900.exe /install /norestart /quiet
}
else {
    start /quiet "https://www.7-zip.org/a/7z1900.exe"
}

Upvotes: 1

Views: 2298

Answers (1)

Ole K
Ole K

Reputation: 869

How about using curl cmdlet?

curl http://some.url --output some.file

Or in your case

curl https://7-zip.org/a/7z1900-x64.msi --output 7z1900-x64.msi

Followed by

7z1900-x64.msi /quiet

(I have used the *.msi file, since the exe does not seem to support a silent installation)

Upvotes: 1

Related Questions