Bonjour et meilleurs voeux à toutes et à tous!
Je suis entrain de "convertir" des scripts .bat en .ps1.
Dans le .bat, j'ai ajouté start /w comme temporisateur pour l'installation d'un soft.
Je cherche la même fonctionnalité sous PowerShell.
Es-ce possible ou non ?
Dois-je juste utiliser la fonction Sleep avec une valeur définie ?
.bat initial :
Code batch : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 start /w <chemin_du_fichier.exe> /VERYSILENT /NORESTART
.bat modifié qui lance le script .ps1 :
Code batch : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 @echo off cls color F chcp 65001>nul set WAY4=C:\Install\Sources set WAY6=C:\Users\%username%\Desktop\Outils\Ressources\Scripts\03DLINSTALL powershell Set-ExecutionPolicy Unrestricted -Force powershell -file %WAY6%\script.ps1
.ps1 modifié pour téléchargement et ensuite installation du soft :
Code powershell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force $OriginalPref = $ProgressPreference # Default is 'Continue' $ProgressPreference = "SilentlyContinue" # Download + Software Install $Dir="C:\Install\Sources" # Téléchargement Soft1 Clear-Host if (!(Test-Path "$Dir\Soft1\Soft1.exe")) { Invoke-WebRequest -Uri "https://urlsoft1.exe" -OutFile "$Dir\Soft1\Soft1.exe" } Sleep 2 Invoke-Command -ScriptBlock { C:\Install\Sources\Soft1\Soft1.exe /VERYSILENT /NORESTART } exit
Merci d'avance pour votre aide.
Partager