-
-
Save BattleNonSense/6cb7cca393f44ba043705962949a179a to your computer and use it in GitHub Desktop.
Connect Network Drives in Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo CONNECT NETWORK DRIVES | |
echo //Created by Battle(non)sense - https://www.youtube.com/BattleNonSense | |
echo -------------------------------------------------------------------- | |
echo This script waits for the network to be ready before connecting the network drives | |
echo -------------------------------------------------------------------- | |
REM We need to wait for the network to get ready first | |
echo . | |
echo Waiting for Network | |
set LC=0 | |
goto :waitfornet_ | |
:waitfornet | |
timeout /t 1 /NOBREAK >nul | |
:waitfornet_ | |
route print -4 | findstr /C:" 0.0.0.0 " >nul 2>nul | |
if not errorlevel 1 goto :ConnectNetDrives | |
set /A LC=%LC%+1 | |
if %LC% LSS 30 goto :waitfornet | |
goto :eof | |
REM Once the network is ready we need to wait a bit before the next step or it might fail on some PC's | |
timeout /t 5 /nobreak >nul | |
:ConnectNetDrives | |
echo . | |
echo Network online, now connecting mapped network shares | |
REM Now we connect the network drives. | |
REM Template without login details: net use DRIVE: PATH /persistent:NO | |
REM net use O: \\server\footage /persistent:NO | |
REM Template with login details: net use DRIVE: PATH /user:NAME PASS /persistent:NO | |
REM net use O: \\server\footage /user:CHRIS MyStrongPazwrd /persistent:NO | |
net use | |
echo . | |
echo Done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment