Can someone explain the following vbs script code

Can someone explain the following vbs script code:

Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set wshShell    = WScript.CreateObject("WScript.Shell")

'initialize logging
 strLogFile = wshShell.ExpandEnvironmentStrings("%TEMP%\CitrixReceiverShortcutClean.log.txt")
 Set objLogFile = objFSO.OpenTextFile(strLogFile, 8, True)
 objLogFile.WriteLine Now & ": Logging Initialized"

'get list of folders in C:\Users
 Set objFolder = objFSO.GetFolder("C:\Users")
 objLogFile.WriteLine Now & ": Got list of user folders under C:\Users"

For Each UserSubFolder in objFolder.SubFolders
	'search the users start menu for Citrix shortcuts
	objStartFolder = UserSubFolder.Path & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs"
	objLogFile.WriteLine Now & ": Searching folder: " & objStartFolder
	If objFSO.FolderExists(objStartFolder) Then
		Set objSearchFolder = objFSO.GetFolder(objStartFolder)
		Set colFiles = objSearchFolder.Files
		For Each objFile in colFiles
		  If InStr(objFile.Name, ".lnk") Then
			IsCitrixShortcut objSearchFolder.Path & "\" & objFile.Name
		  End If
		Next

		ShowSubfolders objFSO.GetFolder(objStartFolder)

		' now search the users desktop for Citrix shortcuts
		objStartFolder = UserSubFolder.Path & "\Desktop"
		objLogFile.WriteLine Now & ": Searching folder: " & objStartFolder

		Set objSearchFolder = objFSO.GetFolder(objStartFolder)
		Set colFiles = objSearchFolder.Files
		For Each objFile in colFiles
			If InStr(objFile.Name, ".lnk") Then
				IsCitrixShortcut objSearchFolder.Path & "\" & objFile.Name
			End If
		Next
		ShowSubfolders objFSO.GetFolder(objStartFolder)
	End If
Next

	objLogFile.WriteLine Now & ": Script complete"

Sub ShowSubFolders(Folder)
     For Each Subfolder in Folder.SubFolders
         Set objFolder = objFSO.GetFolder(Subfolder.Path)
         Set colFiles = objFolder.Files
         For Each objFile in colFiles
		  If InStr(objFile.Name, ".lnk") Then
			IsCitrixShortcut SubFolder.Path & "\" & objFile.Name
		  End If
         Next
         ShowSubFolders Subfolder
     Next
 End Sub

 

Sub IsCitrixShortcut(strShortcut)
  ' CreateShortcut works like a GetShortcut when the shortcut already exists!
  Set objShortcut2 = wshShell.CreateShortcut(strShortcut)
  'WScript.Echo "Target Path       : " & objShortcut2.TargetPath
  If InStr(objShortcut2.TargetPath, "pnagent.exe") Then
   objLogFile.WriteLine Now & ": Deleting PNAgent Shortcut: " & strShortcut
   objFSO.DeleteFile strShortcut, true
  End If
 End Sub

Open in new window

llaravaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
For each folder in c:\users
Go to the start menu path  (C:\<USER>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\)
and it's recursively looking at each shortcut where the target Path contains "pnagent.exe"
If it finds it, it deletes it, logging it to a log file (%TEMP%\CitrixReceiverShortcutClean.log.txt)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kyle AbrahamsSenior .Net DeveloperCommented:
Auto Close.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.