?
Solved

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

Posted on 2008-11-04
6
Medium Priority
?
2,758 Views
Last Modified: 2012-05-05
Hi

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?
0
Comment
Question by:Mystical_Ice
6 Comments
 
LVL 2

Assisted Solution

by:darknoth
darknoth earned 300 total points
ID: 22881084
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
 
	objShortcut.Save
 
	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
	WScript.Echo "Script requires the shortcut, targetpath, and workingdirectory"
	WScript.Echo "parameters from the command line."
	WScript.Echo
	WScript.Echo "The iconlocation, arguments and description parameters are optional."
	WScript.Echo
	WScript.Echo "   cscript //nologo makeshortcut.vbs targetpath workingdir " & _ 
		"[ iconlocation arguments description]"
	WScript.Echo
Else
	For intCounter = 0 to Wscript.Arguments.Count - 1
		Redim Preserve arrArguments(intCounter)
		arrArguments(intCounter) = Wscript.Arguments(intCounter)
	Next
	DoJob()
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

0
 
LVL 14

Accepted Solution

by:
rejoinder earned 400 total points
ID: 22881642
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."
objShortCut.Save

Open in new window

0
 
LVL 7

Assisted Solution

by:firemanf29
firemanf29 earned 300 total points
ID: 22882148
OK.  I'm the lazy one.  Download xxmklink.exe from  http://www.xxcopy.com/download/xxmklink.zip 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

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 7

Expert Comment

by:firemanf29
ID: 22882152
The above will only create the shortcut if the shortcut does not already exist for that user.
0
 
LVL 7

Expert Comment

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

Author Closing Comment

by:Mystical_Ice
ID: 31513301
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

807 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