Aide Fichier Batch

Résolu/Fermé
RAD ZONE Messages postés 5224 Date d'inscription samedi 20 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 - 29 janv. 2018 à 16:13
RAD ZONE Messages postés 5224 Date d'inscription samedi 20 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 - 31 janv. 2018 à 23:32
Bonjour,

Ne connaissant pas pas Widaub 10 je voudrai juste savoir si ces commande sont valables pour W10

ver | find /i "version 10" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 10.0.10586" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 10.0.10240" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 10.0.9926" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 6.4.9879" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 6.4.9860" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 6.4.9841" > nul
if %errorlevel%==0 goto vwin=Windows 10
ver | find /i "version 6.3.9600" > nul
if %errorlevel%==0 goto vwin=Windows 8
ver | find /i "version 6.2." > nul
if %errorlevel%==0 goto vwin=Windows 8
ver | find /i "version 6.1." > nul
if %errorlevel%==0 goto winseven
ver | find /i "version 6.0." > nul
if %errorlevel%==0 goto winseven
ver | find /i "version 5.1." > nul
if %errorlevel%==0 goto winxp
Windows 10
if exist %USERPROFILE%\Bureau\nul (
set Destination="%USERPROFILE%\Bureau\Audit.txt"
) else (set Destination="%USERPROFILE%\Desktop\Audit.txt")
dir/ad/d/o/b "%USERPROFILE%\AppData\Local\un dossier" >"%USERPROFILE%\Desktop\Audit.txt"
goto end
Windows 8
if exist %USERPROFILE%\Bureau\nul (
set Destination="%USERPROFILE%\Bureau\Audit.txt"
) else (set Destination="%USERPROFILE%\Desktop\Audittxt")
dir/ad/d/o/b "%USERPROFILE%\AppData\Local\un dossier" >"%USERPROFILE%\Desktop\Audit.txt"
goto end
:winseven
if exist %USERPROFILE%\Bureau\nul (
set Destination="%USERPROFILE%\Bureau\Audit.txt"
) else (set Destination="%USERPROFILE%\Desktop\Audit.txt")
dir/ad/d/o/b "%USERPROFILE%\AppData\Local\un dossier" >"%USERPROFILE%\Desktop\Audit.txt"
goto end
:winxp
if exist %USERPROFILE%\Bureau\nul (
set Destination="%USERPROFILE%\Bureau\Audit.txt"
) else (set Destination="%USERPROFILE%\Desktop\Audit.txt")
dir/ad/d/o/b "%USERPROFILE%\Local Settings\Application Data\un dossier
" >%Destination%
goto end
:end



il y a longtemp que je n ai pas ecrit un fichier batch !! il y a peut etre plus simple :-)


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 908
Modifié le 31 janv. 2018 à 21:36
Bonjour,

Effectivement il y a trop de répétitions dans ton code, voilà plus simple :

@echo off

set destination=%USERPROFILE%\Desktop\Audit.txt
set dossier1=%USERPROFILE%\AppData\Local\un dossier
set dossier2=%USERPROFILE%\Local Settings\Application Data\un dossier

ver | findstr /i "10. 6.4." >nul && call :fonction "%destination%" "%dossier1%"

ver | findstr /i "6.3. 6.2." >nul && call :fonction "%destination%" "%dossier1%"

ver | findstr /i "6.1. 6.0." >nul && call :fonction "%destination%" "%dossier1%"

ver | findstr /i "5.1." >nul && call :fonction "%destination%" "%dossier2%"

exit

:fonction
dir /ad /d /b "%~2" > "%~1"
goto :eof

rem

Ces commandes sont tout à fait valables pour windows 10.


0
RAD ZONE Messages postés 5224 Date d'inscription samedi 20 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 1 353
31 janv. 2018 à 23:32
Salut

Merci de cette GRANDE simplification :-)

plus je tapais plus je me disais qu il devait y avoir plus simple , mais j etais parti sur ma lancee :-)

merci
A+
0