Skip to content

Instantly share code, notes, and snippets.

@kohlerdominik
Last active December 15, 2018 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohlerdominik/cc65e9182cc035af4804417708e164bc to your computer and use it in GitHub Desktop.
Save kohlerdominik/cc65e9182cc035af4804417708e164bc to your computer and use it in GitHub Desktop.
Reconnect a network from batch. Often this is necessary if you use network drives in a place where you have only wireless access, so when windows initializes the network is not ready yet.
:: HOW-TO ::
:: Copy this file to any directory in your computer
:: Adjust drive letter (dletter) and drive path (dpath)
:: Create a shortcut to the file
:: Change the run mode to minimized in shortcut properties
:: If you want to execute in on start: copy it to "shell:startup" (WIN+R)
:: Set the drive-letter and drive-path
SET dletter=Z:
SET dpath=\\192.168.1.1\dkohler
:connect
:: wait 15 seconds and try to connect
timeout /t 15
net use %dletter% %dpath%
:: if the drive is not connected, jump back to :connect
dir %dletter% || goto connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment