create shortcut to users home drive

Posted on 2014-08-11
Last Modified: 2015-04-08
I need a simple script that will run in setup.bat when users log on that will take their U drive which is their home drives and create a desktop shortcut. Everyone uses the U drive as this is setup in the AD users profiles.
Windows 2003 R2
desktops/laptops windows 7
Question by:jerrywalk1
    LVL 16

    Expert Comment

    by:Michael Ortega (Internetwerx, Inc.)
    I'm a little confused as to what you're trying to accomplish.  Is the U drive a mapped drive shared off the server?  If so, you may consider creating a Group Policy to automatically map the drive for each user that needs it.

    LVL 24

    Expert Comment


    Author Comment

    The network drive is already mapped. All i am trying to do is a script that will create a desktop shortcut to that drive letter.
    LVL 16

    Expert Comment

    by:Michael Ortega (Internetwerx, Inc.)
    Something like this?  It would need a bit of tweaking as I do not know the location of the U drive in your network.

        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objShell = CreateObject("WScript.Shell")

        DesktopPath = objShell.SpecialFolders("Desktop")
        Set NewShortcut = objShell.CreateShortcut(DesktopPath & "\Udrive.lnk")

        If Not objFSO.FileExists (NewShortcut) Then
        NewShortcut.Description = "U Drive"
        NewShortcut.IconLocation = "%SystemRoot%\system32\SHELL32.dll,88"
        NewShortcut.TargetPath = "\\server\locationofUdrive"
        End If

        Set objFSO = nothing
        Set objShell = nothing


    LVL 16

    Accepted Solution

    If you have a U: drive mapped, just create a shortcut to U:\.  Then, place that shortcut to a location readable by all users.  Then, create a batch file that will run at logon that will copy that shortcut from that central loacation to their desktop folder.

    For that batch to work for all users, however, you'd have to use the %userprofile% variable in the batch for the relative location of their local desktop folder.

    For example, for the desktop folder in their local user profile folder, you can use %userprofile%\desktop in place of the full path. That will copy the link to their desktop whether or not they're on server 2003 (which would be C:\Documents and Settings\USERNAME\Desktop) or on Windows 7 (C:\Users\USERNAME\Desktop).

    Or, if you are  in a domain environment, you could use group policy to push out the shortcut to users' desktops. Here's a link that has some screenshots on how to do that:

    If you choose that route, I'd think you'd select "File System Object" for Target Type, then just select Desktop for the location.  For the target path, just type:  J:\

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
    If, like me, you have a lot of Dell servers in the estate you manage this article should save you a little time. When attempting to login to iDrac on any server I would be presented with two errors. The first reads "Do you want to run this applicati…
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

    746 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

    14 Experts available now in Live!

    Get 1:1 Help Now