Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript Login Script To Create Desktop Shortcuts for Specific Domain User

Posted on 2011-09-21
2
Medium Priority
?
1,980 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
jmdl1983 earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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