Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :main
- @ECHO OFF
- TITLE Egnyte Drive Mappings
- if not exist c:\logs mkdir c:\logs
- echo starting script >> c:\logs\logfile.log
- pause
- :remove
- :: Remove existing drive mappings
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "ERMA"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "HR"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Compliance"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Legal"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Marketing"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Archive"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Denver"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "RD"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EQX Shared"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EIAM"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "EQX Funds"
- start "" "C:\Program Files (x86)\Egnyte Connect\EgnyteDrive.exe" -command remove -l "Accounting"
- @NET USE * /delete /y
- :Add
- start net use H: \\xxx.xxx.xxx.xxx\ELC\Shared\ERMA /PERSISTENT:YES
- start net use I: \\xxx.xxx.xxx.xxx\ELC\Shared\HR /PERSISTENT:YES
- start net use J: \\xxx.xxx.xxx.xxx\ELC\Shared\Compliance /PERSISTENT:YES
- start net use L: \\xxx.xxx.xxx.xxx\ELC\Shared\Legal /PERSISTENT:YES
- start net use M: \\xxx.xxx.xxx.xxx\ELC\Shared\Marketing /PERSISTENT:YES
- start net use N: \\xxx.xxx.xxx.xxx\ELC\Shared\Archive /PERSISTENT:YES
- start net use Q: \\xxx.xxx.xxx.xxx\ELC\Shared\Denver /PERSISTENT:YES
- start net use R: \\xxx.xxx.xxx.xxx\ELC\Shared\RD /PERSISTENT:YES
- start net use S: "\\xxx.xxx.xxx.xxx\ELC\Shared\EQX Shared" /PERSISTENT:YES
- start net use T: \\xxx.xxx.xxx.xxx\ELC\Shared\EIAM /PERSISTENT:YES
- start net use X: "\\xxx.xxx.xxx.xxx\ELC\Shared\EQX Funds" /PERSISTENT:YES
- start net use Y: \\xxx.xxx.xxx.xxx\ELC\Shared\Accounting /PERSISTENT:YES
- :: Tell the user what to expect
- ECHO.
- ECHO.
- ECHO Login if prompted and click YES to staying signed in.
- ECHO.
- ECHO.
- ::Set the name of the client's Egnyte domain (enclose in quotes)
- SET domain="clientname"
- ::Run the driveMap subroutine with space separated arguments for
- :: Drive letter
- :: Drive label/name (Enclose in quotes)
- :: Egnyte path (Enclose in quotes)
- CALL :driveMap P "Private" "/Private"
- CALL :driveMap Z "Egnyte Cloud" "/"
- ::Bail out, we're done
- ECHO Mapping complete!
- GOTO :EOF
- :driveMap
- ::Ingest arguments into script variables
- SET driveLetter=%1
- SET label=%2
- SET drivePath=%3
- ECHO Mapping %driveLetter% drive
- ::Check if the drive is mounted, if so, bail out. If not, map it.
- IF EXIST %driveLetter%:\ (GOTO skip) ELSE (GOTO map)
- :skip
- ECHO %driveLetter% drive already mapped - SKIPPING
- ECHO.
- GOTO endDriveMap
- :map
- "C:\Program Files (x86)\Egnyte Connect\egnytedrive.exe" -command add -l %label% -d %domain% -sso use-sso -t %driveLetter% -m %drivePath% -c connect_immediately
- :check
- ::Pause 2 seconds to let Azure AD catchup, mapped? bail out. Not mapped? Just wait longer!
- PING localhost -n 3 >NUL
- IF EXIST %driveLetter%:\ (GOTO endDriveMap) ELSE (GOTO check)
- :endDriveMap
- EXIT /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement