Créer un script bat pour télécharger et installation automatique

xunil2003 Messages postés 766 Date d'inscription   Statut Membre Dernière intervention   -  
barnabe0057 Messages postés 14329 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,

J'ai besoin de réaliser un script bat pour Windows 7, afin d'effectuer une installation automatique de python.
Le script doit télécharger et installer python 2.7.6.
Pouvez-vous me donner un exemple.

@Echo off

Echo Création d'un dossier provisoire pour le téléchargement
c:/
md Téléchargement

Echo Téléchargement de python 2.7.6
......

Echo Installation de python 2.7.6
c:\Téléchargement\fichier-python-2-7-6.exe (?????)

Echo Suppression du dossier Téléchargement
rd c:/Téléchargement

Je ne sais pas :
- Quel commande utilser pour télécharger le fichier depuis une url .
- Comment exécuter le fichier

Merci.

1 réponse

  1. barnabe0057 Messages postés 14329 Date d'inscription   Statut Contributeur Dernière intervention   4 930
     
    Bonjour,

    1) Tout d'abord il faut télécharger wget.exe :

    https://eternallybored.org/misc/wget/

    Il faut copier wget.exe dans C:\Windows\System32

    2) Ensuite tu peux utiliser ce bat :

    @echo off
    title Installation de Python 2
    Mode con cols=120 lines=25

    if exist "%SystemDrive%\Python27\python.exe" goto :eof
    set software=python-2.7.13.msi

    cd %USERPROFILE%\Downloads
    if exist "%software%" del /F /Q "%software%"
    timeout /t 2

    wget64 https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi

    for /f "tokens=*" %%B in ('dir /b *.msi ^| find /i "python-2"') do (msiexec /passive /promptrestart /i "%%~nxB")

    timeout /t 2
    del /F /Q "%software%"

    exit
    0