First version of unified script
This commit is contained in:
121
setupApps.ps1
Normal file
121
setupApps.ps1
Normal file
@@ -0,0 +1,121 @@
|
||||
function InstallMsi {
|
||||
param (
|
||||
[string] $app
|
||||
)
|
||||
Write-Host "Installing $app..."
|
||||
$msiFilePath = Join-Path -Path $tmpPath -ChildPath $app
|
||||
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i `"$msiFilePath`" /qn" -Wait
|
||||
}
|
||||
|
||||
function InstallExeSetup {
|
||||
param (
|
||||
[string] $app
|
||||
)
|
||||
Write-Host "Installing $app..."
|
||||
Start-Process -FilePath $(Join-Path $tmpPath $app) -ArgumentList "/allusers /s" -Wait
|
||||
}
|
||||
|
||||
function InstallExe {
|
||||
param (
|
||||
[string] $app
|
||||
)
|
||||
$appName = [System.IO.Path]::GetFileNameWithoutExtension($app)
|
||||
Write-Host "Installing $appName..."
|
||||
$targetPath = Join-Path $env:ProgramFiles $appName
|
||||
if (-not (Test-Path -Path $targetPath -PathType Container)) {
|
||||
New-Item -Path $targetPath -ItemType Directory
|
||||
}
|
||||
Copy-Item -Path (Join-Path $tmpPath $app) -Destination $targetPath -Force
|
||||
CreateShortcut -exe (Join-Path $targetPath $app) -app $appName
|
||||
}
|
||||
|
||||
function InstallZipSetup {
|
||||
param (
|
||||
[string] $zip,
|
||||
[string] $exe
|
||||
)
|
||||
$zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip)
|
||||
Write-Host "Installing $zipName..."
|
||||
Expand-Archive -Path (Join-Path $tmpPath $zip) -DestinationPath $tmpPath -Force
|
||||
Start-Process -FilePath $(Join-Path -Path $tmpPath -ChildPath (Join-Path -Path $zipName -ChildPath $exe)) -ArgumentList "/allusers /s" -Wait
|
||||
}
|
||||
|
||||
function InstallZip {
|
||||
param (
|
||||
[string] $zip,
|
||||
[string] $exe,
|
||||
[string] $app
|
||||
)
|
||||
$zipName = [System.IO.Path]::GetFileNameWithoutExtension($zip)
|
||||
Write-Host "Installing $zipName..."
|
||||
Expand-Archive -Path (Join-Path $tmpPath $zip) -DestinationPath $env:ProgramFiles -Force
|
||||
if (-not $zipName.Equals($app)) {
|
||||
Move-Item -Path (Join-Path $env:ProgramFiles $zipName) -Destination (Join-Path $env:ProgramFiles $app)
|
||||
}
|
||||
CreateShortcut -exe $(Join-Path -Path $env:ProgramFiles -ChildPath (Join-Path -Path $app -ChildPath $exe)) -app $app
|
||||
}
|
||||
|
||||
function CreateShortcut {
|
||||
param (
|
||||
[string] $exe,
|
||||
[string] $app
|
||||
)
|
||||
$shell = New-Object -ComObject WScript.Shell
|
||||
$shortcut = $shell.CreateShortcut($(Join-Path $env:PUBLIC "Desktop\$app.lnk"))
|
||||
$shortcut.TargetPath = $exe
|
||||
$shortcut.IconLocation = $exe
|
||||
$shortcut.WorkingDirectory = (Get-Item $exe).DirectoryName
|
||||
$shortcut.Save()
|
||||
}
|
||||
|
||||
function CreateURLShortcut {
|
||||
param (
|
||||
[string] $ShortcutName,
|
||||
[string] $TargetUrl
|
||||
)
|
||||
|
||||
$wshShell = New-Object -ComObject "WScript.Shell"
|
||||
$shortcutPath = Join-Path $env:PUBLIC "Desktop\$ShortcutName.url"
|
||||
|
||||
$urlShortcut = $wshShell.CreateShortcut($shortcutPath)
|
||||
$urlShortcut.TargetPath = $TargetUrl
|
||||
$urlShortcut.Save()
|
||||
}
|
||||
|
||||
function InstallApps {
|
||||
param (
|
||||
[string] $Type
|
||||
)
|
||||
|
||||
switch ($Type) {
|
||||
"Labo" {
|
||||
InstallExeSetup -app "winstars_installer.exe"
|
||||
InstallZip -zip "Tectoglob3D-win32-ia32.zip" -exe "Tectoglob3D.exe" -app "Tectoglob3D"
|
||||
InstallExe -app "Sismolog.exe"
|
||||
InstallZip -zip "Tectoglob_11_complet.zip" -exe "TectoGlob.exe" -app "TectoGlob"
|
||||
InstallExe -app "Respipoisson.exe"
|
||||
InstallMsi -app "regressi-mpeg-setup.msi"
|
||||
InstallZip -zip "regavi.zip" -exe "regavi.exe" -app "Regavi"
|
||||
InstallExe -app "Radiochr.exe"
|
||||
InstallZip -zip "Phylogene-Lycee-2021.zip" -exe "Programmes\Phylo.exe" -app "Phylogene"
|
||||
InstallZip -zip "paleoterre_el32.zip" -exe "paleoTerre.exe" -app "PaleoTerre"
|
||||
InstallExeSetup -app "Eduanat2_Setup_2.0.0.exe"
|
||||
InstallZip -zip "couvac_exe.zip" -exe "couvac.exe" -app "Couvac"
|
||||
InstallZipSetup -zip "ACDLabs202311_ChemSketch_FInstall.zip" -exe "setup.exe"
|
||||
}
|
||||
"Info" {
|
||||
InstallZip -zip "simulation.zip" -exe "simulation.exe" -app "Simulation Domotique"
|
||||
InstallMsi -app "EV3_Classroom_Windows_1.5.3_Global.msi"
|
||||
InstallZip -zip "RobotProg.zip" -exe "RobotProg.exe" -app "RobotProg"
|
||||
|
||||
CreateURLShortcut -ShortcutName "Office 365" -TargetUrl "https://office.com/"
|
||||
CreateURLShortcut -ShortcutName "Ecole Direct" -TargetUrl "https://ecoledirecte.com/"
|
||||
CreateURLShortcut -ShortcutName "PIX" -TargetUrl "https://pix.fr/"
|
||||
CreateURLShortcut -ShortcutName "Framindmap" -TargetUrl "https://framindmap.org/"
|
||||
}
|
||||
"Laptop" {
|
||||
Write-Host "Nothing to install."
|
||||
}
|
||||
default { Write-Host "Invalid selection." }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user