?
Solved

Group policy??

Posted on 2003-02-27
3
Medium Priority
?
221 Views
Last Modified: 2012-05-04
I'm trying to write a Login script to map network drives I was wondering ig someone could give an example to look at to see why mine wont run!
0
Comment
Question by:Jayman07
[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
3 Comments
 
LVL 3

Expert Comment

by:netnightmare
ID: 8035755
To map a network drive at startup just use the NET USE command in your script. Here's an extract from the MS Help for this.

Net use
Connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections. The command also controls persistent net connections.

net use [devicename | *] [\\computername\sharename[\volume]] [password | *]] [/user:[domainname\]username] [[/delete] | [/persistent:{yes | no}]]

net use devicename [/home[password | *]] [/delete:{yes | no}]

net use [/persistent:{yes | no}]

Parameters

none

Used without parameters, net use retrieves a list of network connections.

devicename

Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of device names: disk drives (D: through Z:) and printers (LPT1: through LPT3:). Type an asterisk instead of a specific device name to assign the next available device name.

\\computername\sharename

Specifies the name of the server and the shared resource. If computername contains blank characters, enclose the entire computer name from the double backslash (\\) to the end of the computer name in quotation marks (" "). The computer name may be from 1 to 15 characters long.

\volume

Specifies a NetWare volume on the server. You must have Client Service for NetWare (Windows 2000 Professional) or Gateway Service for NetWare (Windows 2000 Server) installed and running to connect to NetWare servers,

password

Specifies the password needed to access the shared resource.

*

Produces a prompt for the password. The password is not displayed when you type it at the password prompt.

/user

Specifies a different user name with which the connection is made.

domainname

Specifies another domain. For example, net use d:\\server\share /user:admin\mariel connects the user identifier mariel as if the connection were made from the admin domain. If domainname is omitted, the current logged on domain is used.

username

Specifies the user name with which to log on.

/delete

Cancels the specified network connection. If the user specifies the connection with an asterisk, all network connections are canceled.

/home

Connects a user to the home directory.

/persistent

Controls the use of persistent network connections. The default is the setting used last. Deviceless connections are not persistent.

yes

Saves all connections as they are made, and restores them at next logon.

no

Does not save the connection being made or subsequent connections. Existing connections are restored at the next logon. Use the /delete switch to remove persistent connections.

Dave
0
 
LVL 1

Accepted Solution

by:
kademing earned 200 total points
ID: 8036336
Here's how you do it using VBScript and WSH.  The following code maps H: to a specific user's home directory on the server and maps G: to a shared folder on the server.  If the username doesn't match the user's home directory then H: will be mapped to the root of the Users folder so the user can browse for their home directory.

<------Begin Code------>

'The following line will force the script to continue running in the event of an error.
on error resume next

Dim oNet, sUser, cInitial, startTime

'Here you're creating a Windows Script Host Network
'Object.  This object has methods and properties that will
'allow you to determine username and map network drives.
Set oNet = CreateObject("WScript.Network")
' Get the user name. On Windows 9x, the use may not be logged
' on when the script starts running; keep checking every 1/2 a
' second until they are logged on.
sUser = oNet.UserName
startTime = Now

Do While sUser = ""
   If DateDiff("s", startTime, Now) > 30 Then Wscript.Quit
   Wscript.Sleep 500
   sUser = oNet.UserName
Loop

'The RemoveNetworkDrive method below is used to force the
'removal of an previous drive mappings for h: and g:.
oNet.RemoveNetworkDrive "h:", True, True
oNet.RemoveNetworkDrive "g:", True, True

'The following two lines map h: and g:.
'Since I specified <b>on error resume next</b>, if there's
'an error because \\Server\Users\UserName doesn't exist
'the next line will be executed and no error message will
'be displayed.
oNet.MapNetworkDrive "h:", "\\Server\Users\" & sUser
oNet.MapNetworkDrive "g:", "\\Server\Shared"

'If the previous mapping for h: was successful, then this
'following line will produce an error, but on error
'resume next will handle that for us.  If the previous
'mapping was NOT successful, then h: will be mapped to
'\\Server\Users
oNet.MapNetworkDrive "h:", "\\Server\Users"

<------End Code------>

This is a working login script, just cut and paste it into a text file and save it with a .vbs extension.  Change <b>Server</b> to your server name and <b>Users</b> and <b>Shared</b> to your network shares and you're good to go.

Hope this helps.
0
 

Author Comment

by:Jayman07
ID: 8038029
Great help thank you so much
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Enterprise networks where VoIP phones have been deployed frequently use port configurations that allow both a computer and an IP phone to be plugged into the same switch port but use different VLANs. On Cisco equipment I'm referring to the "native V…
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

771 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