Category filter
Script to download and install enterprise app (EXE) from its download link
Enterprise apps are apps that are tailored to meet the needs of an organization. At times, organizations may introduce new applications and seek to deploy them across their Windows devices. This can be accomplished through Hexnode UEM’s Execute Custom Script action, allowing the deployment of scripts to automate the downloading and installation of these apps on Windows devices.
In addition to the initial installation, the script can be used to manage updates. Organizations can effectively keep their app versions up to date by executing the script with the latest download link whenever a new update is released. This ensures that the apps are consistently maintained with the latest features, bug fixes, and performance improvements.
Batch script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@echo off set DOWNLOAD_URL=<download_url> set DOWNLOAD_PATH=%TEMP%\your_file.exe set INSTALL_PATH=<installation_path>\Application_name echo Downloading the file from %DOWNLOAD_URL%... bitsadmin.exe /transfer "DownloadJob" %DOWNLOAD_URL% %DOWNLOAD_PATH% echo Installing the application... start /wait "" "%DOWNLOAD_PATH%" /S /D=%INSTALL_PATH% echo Cleanup... del /q %DOWNLOAD_PATH% echo Installation complete |
The script begins by defining variables for the download URL, download path, and installation path. Using bitsadmin.exe, it creates a BITS transfer job named “DownloadJob” to download the .exe file from the URL to the specified location on the device. After a successful download, it silently installs the application. Once installed, the script deletes the downloaded installer and displays “Installation complete”
E.g., To install a program ‘TeamViewer_Setup.exe’ in the Desktop of the user Deborah,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
@echo off set DOWNLOAD_URL=http://download.teamviewer.com/download/TeamViewer_Setup_en.exe set DOWNLOAD_PATH=%TEMP%\TeamViewer_Setup.exe set INSTALL_PATH=C:\Users\Deborah\Downloads\TeamViewer echo Downloading the file from %DOWNLOAD_URL%... bitsadmin.exe /transfer "DownloadJob" %DOWNLOAD_URL% %DOWNLOAD_PATH% echo Installing the application... start /wait "" "%DOWNLOAD_PATH%" /S /D=%INSTALL_PATH% echo Cleanup... del /q %DOWNLOAD_PATH% echo Installation complete |
PowerShell script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Define the download link for the Enterprise app $downloadLink = "download_link" # Define the path where you want to save the downloaded EXE file $downloadPath = "download_path" # Download the EXE file Invoke-WebRequest -Uri $downloadLink -OutFile $downloadPath # Check if the download was successful if (Test-Path $downloadPath) { Write-Host "Download completed successfully." # Install the Enterprise app try { Start-Process -FilePath $downloadPath -Wait -ArgumentList "/S" # Use /S for silent installation Write-Host "Installation completed." } catch { Write-Host "Installation failed: $_" } } else { Write-Host "Failed to download the Enterprise app." } |
The provided script automates the download and installation process of an enterprise app. It defines the download link and local path for saving the downloaded EXE file, proceeds to download the app, verifies the success of the download, and then attempts a silent installation. Upon successful installation, it displays “Installation completed“; otherwise, it indicates a failure.
For example, the following script will download and silently install a program ‘TeamViewer_Setup.exe’:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# Define the download link for the Enterprise app $downloadLink = "http://download.teamviewer.com/download/TeamViewer_Setup_en.exe" # Define the path where you want to save the downloaded EXE file $downloadPath = "C:\Users\allen\Downloads\TeamViewer_Setup.exe" # Download the EXE file Invoke-WebRequest -Uri $downloadLink -OutFile $downloadPath # Check if the download was successful if (Test-Path $downloadPath) { Write-Host "Download completed successfully." # Install the Enterprise app try { Start-Process -FilePath $downloadPath -Wait -ArgumentList "/S" # Use /S for silent installation Write-Host "Installation completed." } catch { Write-Host "Installation failed: $_" } } else { Write-Host "Failed to download the Enterprise app." } |