Solved

VBScript Login Script To Create Desktop Shortcuts for Specific Domain User

Posted on 2011-09-21
2
1,832 Views
Last Modified: 2012-05-12
I have a user who needs quite a few internet shortcuts placed on all her PC's desktops (she has one at each of our offices). I already have a domain script that runs and places three company links on every user's desktop when they login. I need one now that will place her links on only her desktop when she logins on any machine. I will be using group policy. I'm trying to set it up to check and only run based on her AD user name. In the code below I'm using "obama" as the AD user name. I'm getting an error with what I have, and the error shows up when anyone logs in on our domain, not just her.

Aside from not running only for her username, I am getting this error:

Line 104 Char 1
Expected Statement
800A0400
MS VBScript Compilation Error.


Here's the code:

'**************************************************************************************
'* createDesktopIcons.vbs                                                               * 
'* By:  9/20/2011                                                            * 
'* Creates all of user's desktop icons wherever she logins in on the domain.   *
'*                                                                                    * 
'**************************************************************************************

On Error Resume Next

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically grab the user's domain name
DomainString = Wshnetwork.UserDomain 
'Find the Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")

'Grab the user name
UserString = WSHNetwork.UserName
'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName

'Creates Desktop Icons for a certain domain user, in this case Linda Thomas.

'Creates Desktop Icons for a certain domain user, in this case Linda Thomas.
If UserString = "obama" Then
	'calls all of the subroutines that will create the shortcuts.
	createTCMCWebmail()
	createAPDIM()
	createABP()
	createABIM()
	createACGME()
	createMyPatient()
	createAmion()
	createMyEval()
	createEdline()
	createUpToDate()
	createHealthyKids()
	createTCMCMainSite()
	
Else
	WScript.Quit
	
End If

'****Subroutines that create all shortcuts****

'Creates TCMC Webmail Shortcut
Sub createTCMCWebmail()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\TCMC Webmail.url")
	objShortCut.TargetPath = "https://webmail.tcmedc.org/exchange"
	objShortCut.Save
End Sub

'Creates APDIM Shortcut
Sub createAPDIM()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\APDIM.url")
	objShortCut.TargetPath = "http://www.im.org/Pages/Login.aspx?ReturnUrl=%2fAbout%2fAllianceSites%2fAPDIM%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252fAbout%252fAllianceSites%252fAPDIM%252fPages%252fDefault.aspx&Source=%2fAbout%2fAllianceSites%2fAPDIM%2fPages%2fDefault.aspx"
	objShortCut.Save
End Sub

'Creates ABP Shortcut
Sub createABP()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\ABP.url")
	objShortCut.TargetPath = "https://www.abp.org/ABPWebStatic/?anticache=0.525131271614203#murl=homeLogin.html?anticache=0.6539828718612541"
	objShortCut.Save
End Sub

'Creates ABIM Shortcut
Sub createABIM()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\ABIM.url")
	objShortCut.TargetPath = "https://www.abim.org/ONLINE/DEFAULT.ASPX"
	objShortCut.Save
End Sub

'Creates ACGME Shortcut
Sub createACGME()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\ACGME.url")
	objShortCut.TargetPath = "http://www.acgme.org/acWebsite/home/home.asp"
	objShortCut.Save
End Sub

'Creates My Patient Your Patient Shortcut
createMyPatient()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\MyPatientYourPatient.url")
	objShortCut.TargetPath = "https://www.mypatientyourpatient.com/index.jsp"
	objShortCut.Save
End Sub

'Creates Amion Shortcut
Sub createAmion()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\Amion.url")
	objShortCut.TargetPath = "http://amion.com/"
	objShortCut.Save
End Sub

'Creates MyEvaluations Shortcut
createMyEval()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\MyEvaluations.url")
	objShortCut.TargetPath = "https://www.myevaluations.com/Logon.asp"
	objShortCut.Save
End Sub

'Creates Edline Shortcut
createEdline()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\Edline.url")
	objShortCut.TargetPath = "https://www.edline.net/Index.page"
	objShortCut.Save
End Sub

'Creates UpToDate Shortcut
createUpToDate()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\UpToDate.url")
	objShortCut.TargetPath = "http://www.uptodate.com/index"
	objShortCut.Save
End Sub

'Creates HealthyKids Shortcut
createHealthyKids()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\HealthyKids.url")
	objShortCut.TargetPath = "http://www.healthykids.org/"
	objShortCut.Save
End Sub

'Creates TCMC Main Site Shortcut
createTCMCMainSite()
	Set WshShell = WScript.CreateObject("WScript.Shell")
	strDesktop = WshShell.SpecialFolders("Desktop")
	Set objShortCut = WshShell.CreateShortcut(strDesktop & "\TCMC Webpage.url")
	objShortCut.TargetPath = "http://www.thecommonwealthmedical.com/"
	objShortCut.Save
End Sub
'****End of all subroutines****

'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing


'Quit the Script
wscript.quit

Open in new window

0
Comment
Question by:wcgmeit
2 Comments
 
LVL 4

Accepted Solution

by:
jmdl1983 earned 500 total points
ID: 36573940
Quite simple solution actually, you need to add the word "Sub" at the beginning of line(s): 98,116,125,134,143, and 152.  Then your script will process properly.
0
 

Author Comment

by:wcgmeit
ID: 36574010
lol wow. I'm an idiot! Duh! Thank you!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 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