?
Solved

login script map network drive...

Posted on 2006-07-12
5
Medium Priority
?
903 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Accepted Solution

by:
glennbrown2 earned 2000 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

777 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