Group policy??

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!
Jayman07Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

netnightmareCommented:
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
kademingCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jayman07Author Commented:
Great help thank you so much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.