NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

THN's avatar
THN
Aspirant
Dec 29, 2008

Script to Connect to Network Drive

Good Day all,

I've gleaned so much information from these posts, that I thought it's time for me to contribute something, as well. So, here we go:

I have created a little vbscript, which can be run from the start up folder in the start menu, or simply be executed with a shortcut on your desktop. As far as I know, this will only work on the Windows platform.



strLocalDrive = "N:" '<<< Change this to fit your needs.
strRemoteShare = "\\nas-server\Data" '<<< Change this to fit your needs. nas-server could also be an IP address.

Set objNetwork = WScript.CreateObject("WScript.Network")

on error resume next
objNetwork.RemoveNetworkDrive strLocalDrive
on error goto 0

EFlg="set"
While EFlg="set"
strPer = "FALSE"
strUsr = InputBox("Please enter your NAS User Name", "User Name")
strPas = InputBox("Please enter your NAS Password", "Password")
On Error Resume Next
If strUsr="" or strPas="" Then
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer
Else
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strPas
End If
If Err.Number<>0 Then
EFlg="set"
' MsgBox Err.Description
Else
MsgBox "Connected " & strRemoteShare & " successfully to " & strLocalDrive '& ":"
EFlg=""
End If
Wend



Enjoy.

18 Replies

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More