@echo off 
echo.
echo Setting standard DEBIAN EDU Drive Letters:
echo ------------------------------------------
if [%OS%]==[Windows_NT] goto winNT

:win95

::
:: win9x mounts go here
::

rem net use S: %LOGONSERVER%\shared-students

goto:eof

:winNT

::
:: winNT/2k/XP/vista/win7 mounts go here

rem set S_DRIVE=S:
rem set S_SHARE=%LOGONSERVER%\shared-students
rem call :def_mounter_start

goto:eof

:: Only "def" processes below this line!

:def_mounter_start
  set S_DOMOUNT=yes
  net use %S_DRIVE% 2>NUL >NUL
  if [%errorlevel%]==[0] (
    rem echo The drive "%S_DRIVE%" is already mounted
    call :def_mounter_usage
  )
  if [%S_DOMOUNT%]==[yes] (
    call :def_mounter_mount
  )
goto:eof

:def_mounter_usage
  rem net use %S_DRIVE%-find "Öffnungen         0"
  net use %S_DRIVE%|find "ffnungen         0" 2>NUL >NUL
  if [%errorlevel%]==[0] (
    call :def_mounter_unmount
  ) else (
    echo The drive "%S_DRIVE%" is mounted and in use...
    set S_DOMOUNT=no
  )
goto:eof

:def_mounter_unmount
  net use %S_DRIVE% /delete 2>NUL >NUL
  if [%errorlevel%]==[0] (
    echo Unmounted "%S_DRIVE%"
    set S_DOMOUNT=yes
  ) else ( 
    echo Failed to unmount "%S_DRIVE%"
    set S_DOMOUNT=no
  )
goto:eof

:def_mounter_mount
  net use %S_DRIVE% %S_SHARE% /persistent:no 2>NUL >NUL
  if [%errorlevel%]==[0] (
    echo Connected "%S_DRIVE%" to "%S_SHARE%"
  ) else (
    echo Failed to mount "%S_SHARE%" at "%S_DRIVE%"
  )
goto:eof

:: real EOF
