Giter VIP home page Giter VIP logo

network-share-reconnecter's Introduction

Network Share Reconnecter

This project contains a VB script and a Windows Scheduler Task to automatically reconnect disconnected network shares / drives on login or unlock (if they are available or become available in the near future). But why? The reason for creating this project is that attached network drives are under Windows often not correctly reconnected on startup, restart or resume from hibernate / sleep. This still happens with the latest release Windows 10 Fall Creators Update or in my case especially with this release.

Many claim that the reconnect problem leads back to a timing problem during login and the establishment of the network connection over WLAN but there is no official statement from Microsoft as far as I know. There are many registry hacks out there which do not work and do not improve the described behaviour. Moreover this problem already exists for years so I now decided to create a reconnecter which reacts on network availability and share accessability.

Reconnect offline network shares

Example for a reconnect of a drive which was wrongly recognized by Windows as offline.

1

Reconnect not-connected network shares

Example for a reconnect of a drive which was recognized by Windows as not-connected.

2

Prerequisites

  • Windows XP, 7, 8, 8.1, 10
  • little knowledge on Windows Task Scheduling

Download / Installation

  1. Download v1.3.8 of the Network Share Reconnecter Package.
  2. Extract the files.
  3. Modify the sample configuration in the share_reconnect.vbs script file.
    • At least modify hostname, sharePaths and shareLetters (see also the configuration section and #1).
    • Multiple servers can be easily added and configured.
    • Be aware that every host has to support ping, otherwise please deactivate script ping execution (#9)
  4. Copy share_reconnect.vbs to a self defined directory.
  5. Start Windows Task Scheduler - manually or with taskschd.msc.
  6. Import Network_Share_Reconnecter.xml - there are different versions for Windows 7 and 10.
  7. Modify the Scheduler Task.
    • At least change the path to the script which you have chosen before (or do it previously in the Network_Share_Reconnecter.xml).
    • (Optional) Change the user for the defined triggers, by default all computer users will be affected by the script.
    • (Optional) Extend or modify the Scheduler Task depending on your favor and preferences.

Configuration and Parameters

Here a short description of the available parameters which can be configured:

  • Server Configuration

    • hostname - IP or hostname of the remote server (must be modified)
    • sharePaths - all share paths on the server (must be modified)
    • shareLetters - the share / drive letters for the defined paths (must be modified)
    • persistent - should net use create a persistent share (yes/no)
    • user - username for net use authentication if required (optional)
    • password - password for net use authentication if required (optional)
    • secure - defines whether the HTTP or HTTPS protocol should be used (URI only)
  • Global Script Configuration

    • pingEnabled - defines whether the script should use ping availability check
    • pingWait - wait time after failed server ping
    • pingTimeout - how many milliseconds pass before the ping is canceled
    • pingCtn - how many pings per access request should be executed before giving up
    • pingDefaultSrv - use common server if target service rejects pings (URI only)
    • netUseWait - wait time after failed net use
    • netUseCtn - how many net use fails per reconnect are allowed before giving up
    • reconWait - wait time after failed availability check
    • reconAdaptive - boolean to enable automatic reconnection intensity instead of static timeout
    • serverRetryCtn - how many overall reconnection tries should be executed
    • debug - enable or disable debug messages on current reconnection state

UNC Sample Configuration

If your share is accessible over an UNC path like \\192.168.1.1\path\to\share use:

createUncSrvConfig("192.168.1.1", Array("path\to\share"), Array("Z:"), "yes", "", "")

URI Sample Configuration

If your share needs to be accessed over HTTP(S) like http://my.webserver.com/path/to/share use:

createUriSrvConfig("my.webserver.com", Array("path/to/share"), Array("Z:"), "yes", "", "", false)

Features

  • Automatic reconnection of network drives and shares on logon or unlock of the workstation.
  • Stealth script execution (operates without exposing any prompts or windows - except when debug is enabled :P).
  • Self determines server and share availability and accessability.
  • Variable and flexible configuration of polling, timeouts and fallback handling.
  • Configuration of multiple servers together with their shares.
  • Fast ICMP ping checks and adaptive intensity.
  • Scheduling task included (.xml) for easy import.
  • optimized, adaptive and fast reconnection in comparison to simple scripts.

Future Tasks

  • net use analyze to better handle failure states
  • load script config from XML
  • install and configuration app (script)
  • permanent task / hook on event?

Known Issues

There might be an issue which results in an occurring tray icon which states Could not reconnect all network drives:

3

If you want to get rid of this tray icon and the corresponding message you can try to use the .reg files included in this repository. They might also get merged into one of the next releases. There is one file to apply the fix and a second one to restore the previous / original state. Please see also #11 for more approaches to fix this issue.

by thex

Copyright (c) 2019, free to use in personal and commercial software as per the license.

network-share-reconnecter's People

Contributors

jawn avatar thexmanxyz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

network-share-reconnecter's Issues

Tray Icon - "Could not reconnect all network drives"

As reported by a user (Harry), there is an issue causing the below warning when using the Network Share Reconnecter script:

tray_issue

However I'm pretty sure this is not exclusively related to the script and also for me and on my machines it is definitively not occurring after every reboot. It happens just sporadically. Nonetheless, there is a solution for fixing this issue if you get annoyed by this tray warning. Hence, I created two registry scripts which will hopefully fix the issue. There are two scripts in the below archive. One for fixing the issue and one for restoring back to the original state.

Registry_fix.zip

Explanation Readme


To get this issue closed, there are even more approaches to fix this problem. One way you might prevent this notification message is by increasing the <delay> within the scheduler task file or in the corresponding scheduler task. You need to increase the delay for one or both of the triggers defined for the scheduler task. By default they are set to 15S and 10S. A value of 20S or 30S might give better results.

Finally I want to point on this StackOverflow Thread which contains more infos. That's all I can provide on this issue at the moment. It's at least not fixable within the script.

Doesn't work with WebDAV Server?

I am trying to auto-reconnect to my Kolab server.
When connecting through explorer I specify the path as
https://apps.kolabnow.com/files
and type in my username and password; it connects fine.
Maps as K: with the custom name Kolab Now

I have it set like this:
Set srvCfg1 = createUriSrvConfig("apps.kolabnow.com", Array("/files"), Array("K:"), "yes", "username", "password", true)

But when I run the script, it doesn't connect.

Filesystem Check Fails on Unauthenticated Shares

If a share requires manual authentication e.g. the credentials were not stored in the Windows Credential Manager, the filesystem availability check will fail, which prevents the script from reconnecting an UNC share correctly.

Solution:

  • remove FSO checks if credentials are passed or determine if FSO access is possible and only do it if so
  • add functionality to execute net use ?: /delete before reconnecting share

See also Issue #6.

Black screen for minutes and very slow boot/logon

Edit.. oh well.. ofc i only changed the file path to the script.. not the "Start in (optional)".
My VM does not have a D: drive so it couldnt find the folder..
everything works as expected..
i feel so stupid right now.. -.- xD

Check on '\' duplication

If a user passes a share path in the form \path\to\share the leading slash will not be excluded. Improve the share concatination for the net use command! #1

Silent Failure

I'm attempting to re-map drives. With the debug mode on I get a window showing that all of the servers are online, but then there are no other messages, and the drive connections are not refreshed...

I can connect the drives by hand.

Any ideas?

Script OK, Task not?

The script works for me now (thank you) but the task scheduler task does not.
It gives me a "how would you like to open this file" when the task runs.

Add support for whitespaces in share names

Hi there!

Great tool you wrote there. I just reinstalled my windows machine with the FCU and found my network shares being disconnected until I interacted with them in the windows explorer - which is not good. Fortunately, your solution steps in here.

The only problem: I have a network share containing a whitespace. net use-Output for example:
OK N: \\DATENGRAB\TV Shows Microsoft Windows Network

Any idea how to add a share like this? Might wanna extend the script by some "" in there?

Thank you :)

Doesn't seem to work with Windows 10 Pro machines.

First, of all, Andreas, thanks for writing a very cool script. I have one of my test machines is running MySQL and I have a dedicated drive mapping to it, as well as to other server machines. The server machines map just fine with this script, however the W10Pro machine does not and generates a 41301 error. I'm mapping the drives from my Windows 10 Pro for Workstations machine. Here, is a pic of the dialog box generated...

image

Here are some of the configs I've tried:
rem Set srvCfg2 = createUncSrvConfig("mv-mysql", Array("C"), Array("W:"), "yes", "mv-mysql\chris", "xxx")
rem Set srvCfg2 = createUncSrvConfig("198.168.1.162", Array("C"), Array("W:"), "yes", "", "")

Any ideas? Thanks...Chris

wrong password

Hey there! so i'm trying to use your script, since i've got the issue with my networkdrive not reconnection.

It does seem to work, but for some reason it tells me the password is wrong, even though i've entered the correct one.

Set srvCfg1 = createUncSrvConfig("192.168.0.35", Array("Media Server"), Array("Z:"), "yes", "my user", "my password")

Sample Config

It would be really nice to have a sample configuration for the variables in share_reconnect.vbs.

Since i never were in contact with VB before, i would have to look up, how to assign values to the variables and what type is expected (string, int, etc).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.