Solved

login script map network drive...

Posted on 2006-07-12
5
892 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I had the need to build a standalone system to run a point-of-sale system. I’m running this on a low-voltage Atom processor, so I wanted a light-weight operating system, but still needed Windows. I chose to use Microsoft Windows Server 200…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

12 Experts available now in Live!

Get 1:1 Help Now