Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Debug Error On
#Debug Display On
#Include "Win32API.inc"
#Include "wshom.inc" 'Jose include, also loads scrrun.inc
Function PBMain
'create instance of WSH
Local pWsh As IWshShell, pLnk As IWshShortcut
pWsh = NewCom "WScript.Shell"
'info to use in the shortcut
Local targetFolder,targetExe,workingFolder,targetLNK As String
Local sDesktop,comment As String, sPath As Asciiz * %Max_Path
targetFolder = "c:\data\gblaunch" 'folder where EXE resides
targetEXE = "c:\data\gblaunch\gblaunch.exe" 'full path of EXE
workingFolder = "c:\data\gblaunch" 'current directory assigned to EXE process on startup
comment = "My New Shortcut" 'comment for Properties dialog
SHGetFolderPath(0, %CSIDL_DeskTop, 0, 0, sPath) 'sPath contains Desktop folder (AsciiZ)
targetLNK = (sPath) + "\gblaunch.lnk" 'where LNK will reside
'edit content of shortcut, then save
pLnk = pWsh.CreateShortcut(UCode$(targetLNK)) 'uses existing, if already exists
pLnk.Description = UCode$(comment) 'comment for Properties dialog
pLnk.WorkingDirectory = UCode$(workingFolder) 'current directory assigned to EXE process on startup
pLnk.IconLocation = UCode$(targetEXE + " ,0") 'file containing icon, and index of icon (0 is first icon)
pLnk.RelativePath = UCode$(EXE.Path$) '?
pLnk.TargetPath = UCode$(targetEXE) 'EXE full path
pLnk.WindowStyle = %WshNormalFocus 'window style of EXE on startup
pLnk.Save
End Function
'gbs_00728
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm