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

Fermé
xunil2003 Messages postés 761 Date d'inscription mercredi 17 novembre 2004 Statut Membre Dernière intervention 24 mars 2024 - Modifié par xunil2003 le 19/01/2017 à 12:21
barnabe0057 Messages postés 14440 Date d'inscription lundi 2 mars 2009 Statut Contributeur Dernière intervention 19 avril 2024 - 3 avril 2017 à 23:47
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.

A voir également:

1 réponse

barnabe0057 Messages postés 14440 Date d'inscription lundi 2 mars 2009 Statut Contributeur Dernière intervention 19 avril 2024 4 907
Modifié le 4 avril 2017 à 00:03
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