Logon scripts

Need to create a logon script so that xp clients logging onto server 2003 have mapped drives and proxy server settings assigned on logon. Failing dismally in acheiving this would appreciate some pointers.
Who is Participating?
rickardcConnect With a Mentor Commented:
To create your drive mappings you'll need a logon script.  To do the proxy settings you'll need to use a group policy.

To create a logon script for the drive mappings do the following:
Create a text file called logon.bat.  Edit it in notepad and add your drive mapping like fpcit describes.
eg net use f: \\Fileserver\datashare
save the changes and copy it in the netlogon folder on your domain contoller.  eg \\dcname\netlogon.

Then in the active directory users and computers open the user, and go to the profile tab.  Enter logon.bat in the logon script box.

You'll need to wait a little while for the file to be replicated to all your domain controllers before it'll work.  The time this takes will depend on a number of things including how many sites you have and what domain functional level you are using.  Usually 15 minutes is a safe time to wait in a single site environment.

To do the proxy settings you'll need to create a group policy object.  First your should download and install the group policy managment tool (GPMC) from microsoft.  


open the GPMC from administrative tools, expand your domain and browse to the OU where your users are.  Right click on it and select create a GPO in this domain and link it here and give it a name.  Move down to Group policy objects, right click on your new policy and selct edit.  Next expand the user settings > windows settings > internet explorer maintenance > connection.  Double click on proxy settings, enter your proxy server and tick the enabled box.

Then close your policy and wait for your domain to replicate.  That should be it.

Hope that points you in the right direction.
jimstarConnect With a Mentor Commented:
IE stores proxy settings in the registry, so you can execute a command like:
regedit /s z:\proxy.reg

This assumes that the Z drive is mapped properly before the above command executes. As for the reg file:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyServer"="<your proxy IP address>:8080"

fpcitConnect With a Mentor Commented:
The mapped drive can be done with a command called net use and the proxy setting can be handled with a group policy.  

Here is a copy of the syntax for net use

[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME


so you mapped drive may look like this

net use x: \\server1\mappeddrive /user:user@domain.com /persistent:yes

Your users would be prompted for the password or you can put a password in clear text.  Putting a password in clear text isn't the best Idea.

One other thing to consider is if you are trying to map a users home directory this can also be done through Active Directory.  Use the tool Active Directory Users and Computers find the given users and look at the properties.  Find the Profile tab and look at home folder. Here you would map say the "H" drive to \\fileserver\username

Hope that helps
itquestionsConnect With a Mentor Commented:
Here is a vbs script to map drives.  The one section removes all currently mapped drives and then assigns the mappings.  You can also use the boolpersistant command like I have to keep the mappings permanent.

The previous posts on proxy settings are correct.  You should definitely use gpo's for that one.

Dim WSHNetwork, objNetwork, objShell, clDrives, boolPersistent
Set objNetwork = WScript.CreateObject("WScript.Network")
Set WSHNetwork = WScript.CreateObject("WScript.Network")
boolPersistent = True ' True = Persistent ; False = Not Persistent

On Error Resume Next
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True

'Map all drives
objNetwork.MapNetworkDrive "H:", "\\server\share1", boolPersistent
objNetwork.MapNetworkDrive "Z:", "\\server\share2"

rioja_robinAuthor Commented:
Thanks to everyone for their help, very much appreciated.

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.

All Courses

From novice to tech pro — start learning today.