I work in the IT office of a County Government Agency and we are tasked with, among other things, imaging and setting up computers for the employees. One of our application providers has given us an installer for their application that, upon installation, creates randomized folder names within the parent folder. I am looking for a VBScript that will create a shortcut of a .exe from a directory with unknown sub-folder names and place it in the Public Desktop folder. I have also discovered that the vendor has included two instances of the same application in two different sub-folders. I am only interested in using the path from the first .exe located. I found a script online, (unfortunately, I do not remember where I found it. So, I am unable to give credit to the individual who wrote it), that creates a shortcut if the path is known. I have edited the script by adding some variables and including more icon settings for the shortcut. I am extremely new to scripting, so, I am unable to modify this script to find the path to the .exe and then use the path to create the shortcut. The first .exe is located three sub-folders deep and all three folders have randomized names. Any help is greatly appreciated.
' This script creates a shortcut of MyApp and places it in the Public Desktop folder for all users
Option Explicit
Dim objWSH, objFSO, link, desktopPath, AppPath, IconPath, DirPath
DirPath = "C:\Program Files\MyApp Folder\Randomized1\Randomized2\Randomized3"
IconPath = "C:\Program Files\MyApp Folder\Randomized1\Randomized2\Randomized3\ApplicationIcon.ico"
AppPath = "C:\Program Files\MyApp Folder\Randomized1\Randomized2\Randomized3\MyApp.exe"
Set objWSH = WScript.CreateObject("WScript.Shell")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
desktopPath = "C:\Users\Public\Desktop"
' If file exists define where the shortcut should point to
If objFSO.FileExists(AppPath) Then
set link = objWSH.CreateShortcut(desktopPath & "\MyApp.lnk")
' Define icon settings
link.TargetPath = AppPath
link.IconLocation = IconPath
link.Description = "MyApp"
link.WindowStyle = 2
link.WorkingDirectory = DirPath
link.Save
Else
WScript.Echo "Program file does not exist"
End if