Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sharemg2.bat

(view source code of sharemg2.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments
  3. IF "%OS%"=="Windows_NT" (SETLOCAL) ELSE (GOTO Syntax)
  4. IF NOT "%~2"=="" IF /I NOT "%~2"=="/N" GOTO Syntax
  5. ECHO.%* | FIND "?" >NUL && GOTO Syntax
  6. IF "%~1"=="" (SET RemoteSrv=%ComputerName%) ELSE (SET RemoteSrv=%1)
  7. ECHO.%RemoteSrv% | FIND "/" >NUL && GOTO Syntax
  8. PING %RemoteSrv% -n 1 -w 2000 2>&1 | FIND "TTL=" >NUL || GOTO Syntax
  9.  
  10. :: Run the main script
  11. CSCRIPT //NoLogo sharemg2.vbs %RemoteSrv%
  12.  
  13. :: For servers with lots of shares a sorted version of the batch file is created
  14. ECHO.
  15. ECHO @ECHO OFF> %RemoteSrv%_recreate_shares_sorted.bat
  16. TYPE %RemoteSrv%_recreate_shares.bat | FIND /I /V "@ECHO OFF" | FIND /I /V "GOTO:EOF" | SORT >> %RemoteSrv%_recreate_shares_sorted.bat
  17. ECHO GOTO:EOF>> %RemoteSrv%_recreate_shares_sorted.bat
  18.  
  19. :: Done
  20. PAUSE
  21. GOTO:EOF
  22.  
  23.  
  24. :Syntax
  25. ECHO.
  26. ECHO ShareMg2.bat,  Version 2.00 for Windows Server 2003
  27. ECHO Helper batch file for ShareMg2.vbs, a script to display and log
  28. ECHO shares on the specified server, and create a batch file to recreate
  29. ECHO these shares.
  30. ECHO Written for migrations of file servers to Windows Server 2003.
  31. ECHO.
  32. ECHO Usage:  SHAREMG2.BAT  [ servername ]
  33. ECHO.
  34. ECHO Where:  "servername"  is the optional name of the server to be probed
  35. ECHO                       (default is local computer name)
  36. ECHO.
  37. ECHO ShareMg2.bat requires ShareMg2.vbs. ShareMg2.vbs creates a batch file
  38. ECHO named servername_recreate_shares.bat, and a text file listing the original
  39. ECHO shares. ShareMg2.bat will also create a sorted version of
  40. ECHO servername_recreate_shares.bat, named servername_recreate_shares_sorted.bat.
  41. ECHO Use the latter to recreate the file shares on a new server. Remove the /GRANT
  42. ECHO part in the batch files to use them with Windows 2000 servers.
  43. ECHO.
  44. ECHO Written by Rob van der Woude
  45. ECHO http://www.robvanderwoude.com
  46. IF "%OS%"=="Windows_NT" ENDLOCAL
  47.  

page last uploaded: 2017-08-21, 14:26