Tuesday, August 19, 2008

Deploy Shortcut

I give credit to a co-worker of mine. We were deploying Hummingbird (3270 Terminal program) and we needed to create a shortcut to a predefined location for each person.

Here is a vbscript example of how to create a shortcut link on the fly


--------------------------------------------
'declare variables
dim WshShell, fso, oShellLink, strDesktop, strAppData

'set variables
set WshShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
strDesktop = WshShell.SpecialFolders("Desktop")
strAppData = WshShell.ExpandEnvironmentStrings("%AppData%")

'do they have the profile data in their My Profile Space
if fso.FileExists(strAppData & "\Hummingbird\Connectivity\13.00\Profile\XYZ.hep") then
'create shortcut
set oShellLink = WshShell.CreateShortcut(strDesktop & "\VTAM.lnk")
oShellLink.TargetPath = strAppData & "\Hummingbird\Connectivity\13.00\Profile\VTAM.hep"
oShellLink.WindowStyle = 1
oShellLink.Description = "Hover description here"
oShellLink.Save
else
'they don't have them in the My Profile Space, should I move them there?
end if
--------------------------------------------------