Solved

login script map network drive...

Posted on 2006-07-12
5
891 Views
Last Modified: 2012-08-13
Hi:

i need a login script to map network drives,so i wrote a script using wscript.shell(vbs),
then use the net use command to disconnect drive first then remap these drive,
i need map three network drive,but when i reboot the computer,the map drive just appear two...
if i  logout then login these network drives map success,and i can see all three network drive...
anyone know how to solve it??  

thanks
0
Comment
Question by:darkeryu
5 Comments
 
LVL 6

Accepted Solution

by:
glennbrown2 earned 500 total points
ID: 17092579
i use this to map my drives

***********************************
On Error Resume Next

'Declare variables
Dim wshNetwork, fso, strComputer, objUser, objPolicy, objFirewall

'Set variables
Set wshNetwork = CreateObject("WScript.Network")
Set objShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set strComputer = WshNetwork.ComputerName

'check existing drives if connected
If fso.DriveExists ("G:") = True Then
WshNetwork.RemoveNetworkDrive "G:"
End If

If fso.DriveExists ("H:") = True Then
WshNetwork.RemoveNetworkDrive "H:"
End If

'map network drives
wshNetwork.MapNetworkDrive "G:", "\\SERVER1\Company"

wshNetwork.MapNetworkDrive "H:", "\\SERVER1\" & wshNetwork.UserName&"$"

'reset variables to nothing
Set wshNetwork = Nothing
Set fso = Nothing
Set objUser = Nothing
Set strComputer = Nothing
***************************************************************
0
 
LVL 16

Expert Comment

by:glenn_1984
ID: 17092717
You could also use a simple batch file.

net use f: /d   (disconnect drive first)
net use f: //servername/sharename  (map drive f:)
net use  //servername/sharename (map directly to share)
0
 
LVL 14

Expert Comment

by:canali
ID: 17095273

::mapThreeDrive.cmd
@echo off
::delete shares if exist
if exist f:\NUL  net use f: /d
if exist g:\NUL net use g: /d
if exist h:\NUL net use h: /d
:: map network drives
net use f: \\servername\one
net use g:  \\servername\two
net use h:  \\servername\three
0
 
LVL 6

Author Comment

by:darkeryu
ID: 17096468
hi all:

i know how to map it,but when i map network drive,not all network drives remap,if client reboot...
but when users loginout and login again all network drives will be map...

thanks
0
 
LVL 16

Expert Comment

by:glenn_1984
ID: 17108193
are you using
net use f: /d  (delete the mapping - before you try to create the mapping?)

or have you tried

net use f: /persistent:yes
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
Learn about cloud computing and its benefits for small business owners.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now