Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :main
  2. @ECHO OFF
  3. TITLE Egnyte Drive Mappings
  4. if not exist c:\logs mkdir c:\logs
  5. echo starting script >> c:\logs\logfile.log
  6. pause
  7.  
  8. :remove
  9. :: Remove existing drive mappings
  10. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "ERMA"
  11. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "HR"
  12. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Compliance"
  13. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Legal"
  14. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Marketing"
  15. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Archive"
  16. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Denver"
  17. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "RD"
  18. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EQX Shared"
  19. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EIAM"
  20. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EQX Funds"
  21. start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Accounting"
  22.  
  23. @NET USE * /delete /y
  24.  
  25.  
  26. :Add
  27. start net use H: \\xxx.xxx.xxx.xxx\ELC\Shared\ERMA /PERSISTENT:YES
  28. start net use I: \\xxx.xxx.xxx.xxx\ELC\Shared\HR /PERSISTENT:YES
  29. start net use J: \\xxx.xxx.xxx.xxx\ELC\Shared\Compliance /PERSISTENT:YES
  30. start net use L: \\xxx.xxx.xxx.xxx\ELC\Shared\Legal /PERSISTENT:YES
  31. start net use M: \\xxx.xxx.xxx.xxx\ELC\Shared\Marketing /PERSISTENT:YES
  32. start net use N: \\xxx.xxx.xxx.xxx\ELC\Shared\Archive /PERSISTENT:YES
  33. start net use Q: \\xxx.xxx.xxx.xxx\ELC\Shared\Denver /PERSISTENT:YES
  34. start net use R: \\xxx.xxx.xxx.xxx\ELC\Shared\RD /PERSISTENT:YES
  35. start net use S: "\\xxx.xxx.xxx.xxx\ELC\Shared\EQX Shared" /PERSISTENT:YES
  36. start net use T: \\xxx.xxx.xxx.xxx\ELC\Shared\EIAM /PERSISTENT:YES
  37. start net use X: "\\xxx.xxx.xxx.xxx\ELC\Shared\EQX Funds" /PERSISTENT:YES
  38. start net use Y: \\xxx.xxx.xxx.xxx\ELC\Shared\Accounting /PERSISTENT:YES
  39.  
  40.  
  41. :: Tell the user what to expect
  42. ECHO.
  43. ECHO.
  44. ECHO Login if prompted and click YES to staying signed in.
  45. ECHO.
  46. ECHO.
  47.  
  48. ::Set the name of the client's Egnyte domain (enclose in quotes)
  49. SET domain="clientname"
  50.  
  51. ::Run the driveMap subroutine with space separated arguments for
  52. ::      Drive letter
  53. ::      Drive label/name (Enclose in quotes)
  54. ::      Egnyte path (Enclose in quotes)
  55. CALL :driveMap P "Private" "/Private"
  56. CALL :driveMap Z "Egnyte Cloud" "/"
  57.  
  58.  
  59. ::Bail out, we're done
  60. ECHO Mapping complete!
  61. GOTO :EOF
  62.  
  63.  
  64. :driveMap
  65. ::Ingest arguments into script variables
  66. SET driveLetter=%1
  67. SET label=%2
  68. SET drivePath=%3
  69. ECHO Mapping %driveLetter% drive
  70. ::Check if the drive is mounted, if so, bail out. If not, map it.
  71. IF EXIST %driveLetter%:\ (GOTO skip) ELSE (GOTO map)
  72.     :skip
  73.         ECHO %driveLetter% drive already mapped - SKIPPING
  74.         ECHO.
  75.         GOTO endDriveMap
  76.     :map
  77.         "C:\Program Files (x86)\Egnyte Connect\egnytedrive.exe" -command add -l %label% -d %domain% -sso use-sso -t %driveLetter% -m %drivePath% -c connect_immediately
  78.     :check
  79.         ::Pause 2 seconds to let Azure AD catchup, mapped? bail out. Not mapped?  Just wait longer!
  80.         PING localhost -n 3 >NUL
  81.         IF EXIST %driveLetter%:\ (GOTO endDriveMap) ELSE (GOTO check)
  82. :endDriveMap
  83.  
  84.  
  85. EXIT /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement