Aide Fichier Batch
Résolu
RAD ZONE
Messages postés
5230
Date d'inscription
Statut
Contributeur
Dernière intervention
-
RAD ZONE Messages postés 5230 Date d'inscription Statut Contributeur Dernière intervention -
RAD ZONE Messages postés 5230 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Ne connaissant pas pas Widaub 10 je voudrai juste savoir si ces commande sont valables pour W10
il y a longtemp que je n ai pas ecrit un fichier batch !! il y a peut etre plus simple :-)
merci
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:
- Aide Fichier Batch
- Fichier bin - Guide
- Fichier epub - Guide
- Fichier rar - Guide
- Fichier batch - Guide
- Comment réduire la taille d'un fichier - Guide
1 réponse
Bonjour,
Effectivement il y a trop de répétitions dans ton code, voilà plus simple :
Ces commandes sont tout à fait valables pour windows 10.
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.
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+