Solved

VBScript Login Script To Create Desktop Shortcuts for Specific Domain User

Posted on 2011-09-21
2
1,797 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…

708 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