{{:folder-yellow-parent-icon.png?nolink&24|}} [[info:windows_sommaire|Revenir au sommaire]]\\ ====== Script de montage de lecteurs réseaux ====== Le script ci-dessous peut être lancé tel quel et fera apparaître un menu ou il peut être appelé en ligne de commande / depuis un raccourci avec les paramètres suivants :\\ * /unmount démonte tous les lecteurs (pas seulement ceux définis dans le script) * /mount monte tous les lecteurs définis par les variables path# * /? ou /help message d'aide à la syntaxe * /version affiche la version du script @echo off REM variables definition set ver_network=7 REM special characters table (most used) REM replace the accentuated char by its DOS value in path# and desc# vars REM windows | DOS REM â | ƒ REM à | … REM ä | „ REM é | ‚ REM ê | ˆ REM è | Š REM ë | ‰ REM î | Œ REM ï | ‹ REM ô | “ REM ö | ” REM û | – REM ù | — REM ü |  REM Set the environment variables path# and desc# REM example: REM pathA="\\server_name.local\my share with spaces\%username%" REM descA=The description of my share (optional) set pathA= set descA= set pathB= set descB= set pathE= set descE= set pathF= set descF= set pathG= set descG= set pathH= set descH= set pathI= set descI= set pathJ= set descJ= set pathK= set descK= set pathL= set descL= set pathM= set descM= set pathN= set descN= set pathO= set descO= set pathP= set descP= set pathQ= set descQ= set pathR= set descR= set pathS= set descS= set pathT= set descT= set pathU= set descU= set pathV= set descV= set pathW= set descW= set pathX= set descX= set pathY= set descY= set pathZ= set descZ= REM command line parameters if "%1"=="" set interactive=oui if "%1"=="/unmount" goto unmountAll if "%1"=="/mount" goto mountAll if "%1"=="/?" goto syntaxe if "%1"=="/help" goto syntaxe if "%1"=="/version" goto version REM Main menu if defined interactive call mode con cols=80 lines=50 echo Mapping network drives v%ver_network% echo ------------------------- :mainmenu echo. echo Choose your option: echo - Unmount all drives. echo + Mount all drives. echo 1 mount only 1 drive. echo ? List drives. echo 0 Quit. echo. set /p choix=Your choice: if not "%choix%"=="" set lettre=%choix:~0,1% if #%choix%==#- goto unmountAll if #%choix%==#+ goto mountAll if #%choix%==#1 goto mount1 if #%choix%==#? goto showDrives if #%choix%==#0 goto fin echo Out of range! goto mainmenu :unmountAll echo. echo Unmount all network drives... call net use * /delete /y if ERRORLEVEL 1 goto fin if ERRORLEVEL 0 echo Unmount OK! if defined interactive goto mainmenu goto fin :mountAll for %%a in (A B E F G H I J K L M N O P Q R S T U V W X Y Z) do if defined path%%a call :mount %%a if defined interactive goto mainmenu goto fin :mount1 :showDrives cls echo List defined drives echo. call :listelecteurs if #%choix%==#? goto mainmenu echo. echo 7 Main menu echo 0 Quit echo. set /p lettre=Your choice: if not "%lettre%"=="" call :UpperCase lettre set lettre=%lettre:~0,1% if %lettre%==7 goto mainmenu if %lettre%==0 goto fin for %%a in (A B E F G H I J K L M N O P Q R S T U V W X Y Z) do if %lettre%==%%a call :mount %%a if defined interactive goto mainmenu goto fin :mount REM Subroutine : mount a network drive echo. echo Mount drive %1: echo Path: %%path%1%% echo Description: %%desc%1%% if exist %1:\. call net use %1: /delete if defined path%1 call net use %1: %%path%1%% /persistent:yes GOTO:EOF :UpperCase REM Subroutine : convert a variable VALUE to all UPPER CASE. REM The argument for this subroutine is the variable NAME. for %%i in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z") do call set "%1=%%%1:%%~i%%" GOTO:EOF :listelecteurs REM Subroutine : list configured drives (path# vars) for %%a in (A B E F G H I J K L M N O P Q R S T U V W X Y Z) do if defined path%%a call echo %%a %%path%%a%% (%%desc%%a%%) GOTO:EOF :version echo. echo %0 version %ver_network% goto fin :syntaxe echo. echo Syntax : %0 [/mount^|/unmount^|/version] echo. echo /mount : mount all configured network drives echo /unmount : unmount all drives echo /version : show version :fin set ver_network= set interactive= set lettre= set choix= for %%a in (A B E F G H I J K L M N O P Q R S T U V W X Y Z) do if defined path%%a call set path%%a= for %%a in (A B E F G H I J K L M N O P Q R S T U V W X Y Z) do if defined desc%%a call set desc%%a=