ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

[Win][Suggestions needed] Ensure network shares are connected reliably at login?

<< < (2/2)

Shades:
Maybe it is even smarter to extend the script from 4wd to include:
net use X: \\SERVER\Share

X:           =  drive letter
\\SERVER = computer name or it's IP address. With the IP address, which barely changes in a LAN, no extra subsystem is needed to translate to an IP address. Faster and more reliable.
\Share     = the name of the share

That recreates the share and if the connection already exist it should make Windows mark the connection as active.

You can also go on with it in a blunt matter and remove the connection (net remove X:) every time you turn your system off and as one of the first things in your startup procedure you simply recreate the connection again.

UNC is always preferable, just as 4wd suggested. Much less of a hassle.

Another tip that could make your situation better is the following:
Open Control panel, then open credential manager and add windows credentials for the NAS device (IP address, user name and password). Once such a credential is created Windows will use those immediately instead of trying to make a connection using the credentials of the user account you used to log into Windows itself. Normally this procedure doesn't take much time, but you can shave time off when you create such a credential.

Always remember that TCP/IP are old protocols and that they were designed for unreliable networks. That means a TCP connection can wait for a max of 30 seconds before it marks a connection/session as bad. While that is the extreme, all the times TCP waits does add up and might take you out of the connection window allowed to connect to your share.

4wd:
This thread was about a similar problem, there didn't seem to be any resolution regarding mapped drives then either.

But who knows, maybe something in there will work better on 10 than it did on 7.

EDIT: Also this old PoSh script I did might provide some inspiration.

wreckedcarzz:
So I searched a bit more and came across this, with the 'net use' command mentioned here. With modification, it seems to work, and is quick enough on login to work; again, I don't know much about much beyond single-line shell commands; is this the proper way of doing this? I also had saved the login credentials when I initially set the shares up (not sure if that's separate from the credential manager)..

I'm also still using the machine name over the IP here, and it doesn't *seem* to matter - I have almost 40 devices on my network, but the NAS has a static IP via the router.. (I was using the IP as posts about similar questions said that it was recommended as a solution for this initial issue, but it made no difference in the mapped shares, so I switched back).


--- ---@echo off

:Start
timeout /t 1 /nobreak >NUL
if exist W:\ X:\ Y:\ Z:\ NUL goto End
net use W: \\NAS\backups /PERSISTENT:YES
net use X: \\NAS\homes /PERSISTENT:YES
net use Y: \\NAS\media /PERSISTENT:YES
net use Z: \\NAS\temp /PERSISTENT:YES
if ERRORLEVEL 1 goto exit
:End

I imagine there are differences between cmd and ps, and so this doesn't have the retry function/I am in no way skilled with either tool to try and combine them, which is unfortunate, but initial tests seemed to work for me.

Thoughts?

4wd:
Something like that:


--- Code: PowerShell ---$w = $x = $y = $z = $true do {  if (!(Test-Path W:\)) {    Start-Process -FilePath "net.exe" -ArgumentList "use W: \\NAS\backups /PERSISTENT:YES" -Wait -WindowStyle Hidden  } else {    $w = $false  }  if (!(Test-Path X:\)) {    Start-Process -FilePath "net.exe" -ArgumentList "use W: \\NAS\homes /PERSISTENT:YES" -Wait -WindowStyle Hidden  } else {    $x = $false  }  if (!(Test-Path Y:\)) {    Start-Process -FilePath "net.exe" -ArgumentList "use W: \\NAS\media /PERSISTENT:YES" -Wait -WindowStyle Hidden  } else {    $y = $false  }  if (!(Test-Path Z:\)) {    Start-Process -FilePath "net.exe" -ArgumentList "use W: \\NAS\temp /PERSISTENT:YES" -Wait -WindowStyle Hidden  } else {    $z = $false  }} while ($w -or $x -or $y -or $z)
Haven't tested it but the theory is sound  :)

Navigation

[0] Message Index

[*] Previous page

Go to full version