#COMPILE EXE "linkexec.exe" #DIM ALL #RESOURCE "linkexec.pbr" '------------------------------------------------------------------------------ ' ** Includes ** '------------------------------------------------------------------------------ #INCLUDE ONCE "WIN32API.INC" #INCLUDE ONCE "SHORTCUT.INC" '------------------------------------------------------------------------------ '------------------------------------------------------------------------------ ' ** Main Application Entry Point ** '------------------------------------------------------------------------------ FUNCTION PBMAIN() LOCAL lnk AS LINKTYPE LOCAL arg AS STRING LOCAL s AS STRING s = TRIM$(COMMAND$(1), ANY $SPC+$TAB+$DQ) IF RIGHT$(LCASE$(s), 4) <> ".lnk" THEN ?"Error: argument(s) needed."+$CR+$CR _ +"Either call ""linkexec myshortcut.lnk my_parameters"""+$CR _ +"on the command line"+$CR _ +"-or-"+$CR _ +"drag and drop a Windows shortcut onto"+$CR _ +"this program, to launch it without argument." _ ,%MB_ICONINFORMATION ,"linkexec" EXIT FUNCTION END IF ' Get the remaining arguments arg = TRIM$(REMOVE$(COMMAND$, COMMAND$(1))) ' Parse shortcut filepath from argument lnk.zLinkFolder = PATHNAME$(PATH, s) lnk.zLinkName = PATHNAME$(NAMEX, s) ' Read all fields shortcut ReadShortcut(lnk) ' Merge arguments lnk.zArguments = TRIM$(lnk.zArguments + " " + arg) ' Launch the target program with its parameters, in the specified workdir SHELLEXECUTE BYVAL 0, "open", lnk.zExeName, lnk.zArguments, lnk.zWorkDir, %SW_SHOWNORMAL END FUNCTION '------------------------------------------------------------------------------