Logon scripts

Posted on 2007-10-09
Last Modified: 2010-04-03
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.
Question by:rioja_robin
    LVL 4

    Assisted Solution

    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"

    LVL 3

    Assisted Solution

    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 / /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
    LVL 1

    Accepted Solution

    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.
    LVL 4

    Assisted Solution

    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"


    Author Comment

    Thanks to everyone for their help, very much appreciated.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
    Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    779 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

    21 Experts available now in Live!

    Get 1:1 Help Now