Logon script (VB) to create shortcut on desktop to "Startup" folder for user session

Posted on 2008-11-04
Last Modified: 2012-05-05

We have a terminal server, and used to have a VB script (that, as part of group policy, would run when the user logged in) to create a "Startup" folder on their desktop.  The folder was actually a shortcut to their user session 'startup' folder.  We found many users were too computer illiterate to navigate to the 'startup' in the program files directory, and then try to figure out how to drag and drop programs there, so with the folder on the desktop, they could drag 'messenger', 'outlook', etc. into it and when they logged on it would open them up.

Due to a domain controller crash, we lost most of the data, and i'd like to find that script again.  Could anyone help please?
Question by:Mystical_Ice
    LVL 2

    Assisted Solution

    Here's a piece of code that will create the shortcut for you.  I don't know how you would add it to your logon script.

    Option Explicit
    Function MakeShortcut(sShortcut, sTarget, sWorking, sIcon, sArgs, sDesc)
    	Dim objShell, objShortcut, objWorkingDirectory, objArguments, objDescription
    	Set objShell = WScript.CreateObject("WScript.Shell")
    	Set objShortcut = objShell.CreateShortcut(sShortcut)
    	objShortcut.TargetPath = sTarget
    	If sIcon <> "" Then objIconLocation = sIcon
    	objWorkingDirectory = sWorking
    	If sArgs <> "" Then objArguments = sArgs
    	If sDesc <> "" Then objDescription = sDesc
    	Set objDescription = Nothing
    	Set objArguments = Nothing
    	Set objWorkingDirectory = Nothing
    	Set objShortcut = Nothing
    	Set objShell = Nothing
    End Function
    ' Main
    Dim arrArguments(), intCounter
    If Wscript.Arguments.Count = 0 Then
    	WScript.Echo "This script creates a shortcut in a location specified at runtime "
    	WScript.Echo "by command line parameters."
    	WScript.Echo "Script requires the shortcut, targetpath, and workingdirectory"
    	WScript.Echo "parameters from the command line."
    	WScript.Echo "The iconlocation, arguments and description parameters are optional."
    	WScript.Echo "   cscript //nologo makeshortcut.vbs targetpath workingdir " & _ 
    		"[ iconlocation arguments description]"
    	For intCounter = 0 to Wscript.Arguments.Count - 1
    		Redim Preserve arrArguments(intCounter)
    		arrArguments(intCounter) = Wscript.Arguments(intCounter)
    End If
    Sub DoJob()
    	Dim strShortcut, strTarget, strWorkingDir, strIconLoc, strArguments, strDescription
    	Dim intRetVal
    	strShortcut = arrArguments(0)
    	strTarget = arrArguments(1)
    	strWorkingDir = arrArguments(2)
    	strIconLoc = ""
    	strArguments = ""
    	strDescription = ""
    	If intCounter > 3 Then
    		strIconLoc = arrArguments(3)
    		If intCounter > 4 Then strArguments = arrAgruments(4)
    		If intCounter > 5 Then strDescription = arrArguments(5)
    	End If
    	intRetVal = MakeShortcut(strShortcut, strTarget, strWorkingDir, strIconLoc, _
    		strArguments, strDescription)
    End Sub

    Open in new window

    LVL 14

    Accepted Solution

    Mine is a little shorter but will add the shortcut onto the desktop as requested.

    Set objShell = CreateObject("Wscript.Shell") 
    strUserProfile = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
    Set objShortCut = objShell.CreateShortcut(strUserProfile & "\Desktop\Startup Folder.lnk")
    objShortCut.TargetPath = "%Userprofile%\Start Menu\Programs\Startup"
    objShortCut.Description = "Drag and drop files here to launch them at startup."

    Open in new window

    LVL 7

    Assisted Solution

    OK.  I'm the lazy one.  Download xxmklink.exe from and place in the netlogon folder on your DC.

    Add the following to your login script (BAT or CMD file) on one line.

    if not exist "%Userprofile%\Desktop\Startup Folder.lnk" %logonserver%\netlogon\xxmklink.exe "%Userprofile%\Desktop\Startup Folder.lnk" "%Userprofile%\Start Menu\Programs\Startup" " " "%Userprofile%\Start Menu\Programs\Startup" "Startup Folder" 1
    if not exist "%Userprofile%\Desktop\Startup Folder.lnk" %logonserver%\netlogon\xxmklink.exe "%Userprofile%\Desktop\Startup Folder.lnk" "%Userprofile%\Start Menu\Programs\Startup" " " "%Userprofile%\Start Menu\Programs\Startup" "Startup Folder" 1 

    Open in new window

    LVL 7

    Expert Comment

    The above will only create the shortcut if the shortcut does not already exist for that user.
    LVL 7

    Expert Comment

    Oh.  That can also be placed in teh System Startup folder on a specific server if you only want it to affect that server.

    Author Closing Comment

    Thanks guys - much appreciated.  Since you all had a solution, I divided the points, but gave more points to rejoinder, since i ended up using his.

    Thanks again

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
    On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
    Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now