Skip to content

Instantly share code, notes, and snippets.

@thetredev
Last active August 30, 2019 13:54
Show Gist options
  • Save thetredev/9ca530ec12935bd811ad05b468f2ab1f to your computer and use it in GitHub Desktop.
Save thetredev/9ca530ec12935bd811ad05b468f2ab1f to your computer and use it in GitHub Desktop.
Batch file to fix "red crossed" network drives (on Windows logon)
:: This script will open instances of explorer.exe at specific locations,
:: and kill explorer.exe after 1 second when all explorer windows are open.
:: I personally use it to make Windows realize that my network drives
:: are actually online and don't show a red cross after I login.
:: I have my Steam library on a network drive which gets disabled
:: when Steam doesn't see it. Therefore I wrote this little workaround.
:: To run it on logon, do the following:
:: 1. Put this file somewhere accessible, like C:
:: 2. Create a scheduled task and select the following options:
:: - General
:: * Select a user to run the script
:: * "Only execute when the user is logged on"
:: * Configure for: <your Windows version>
:: - Trigger
:: * At logon (for every users)
:: - Action
:: * Path to this script
:: Of course, you can just try it out by double clicking it.
:: Enjoy!
@echo off
:: -- Configuration start --
:: The list of paths to open up using an explorer.exe instance
set "explorer_paths=D: E:"
:: -- Configuration end --
:: Run explorer.exe for <explorer_paths>
(for %%i in (%explorer_paths%) do (
explorer %%i
))
:: Wait 1 second to ensure that Windows actually 'sees' the paths
timeout 1 > NUL
:: Kill all instances of explorer.exe silently
taskkill /IM "explorer.exe" /F >nul 2>&1
:: Start explorer.exe in the background
start explorer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment