I'd like to have this confirmed before I write another bug report (or is there one already? not found)
This seems to be a very old bug, I see it in Win versions from 6.7.10 to the freshest RCs.
I've a sample stack attached, feel free to try yourselves - I hope it's not limited to my machines :)
When, in Windows, you call:
Code: Select all
launch "D:/myDir/myFile.txt" with "D:/myDir/myApp.exe"
But you just have created a zombie process "myApp.exe".
If you'll repeat it, the same will happen.
"the result" will be empty or a (random?) number; when repeated, this again or sometimes "process is already open".
Find & kill the process in taskmanager, tab -2 (details).
This is evil, because it's the only way LC provides to open a document with a certain (not default) program. For instance, you may have Adobe suite installed, but you want a small, quick PDF viewer (SumatraPDF etc.) to safely display PDFs.
We could call:
Code: Select all
get shell("D:/myDir/myApp.exe" "D:/myDir/myFile.txt")
The workaround - we define a custom command:
Code: Select all
on LaunchWith theDocPath, theAppPath
/* - Does what "launch [docPath] with [appPath]" is supposed to do -
(both theDocPath & theAppPath are expected to be full paths (as from "ask file ...")
Set up variables & defaultFolder: */
put the defaultFolder into myOldDF
set itemdel to slash
put item 1 to -2 of theAppPath into myAppPath
put item -1 of theAppPath into myAppName
if char 1 of myAppname = slash then delete char 1 of myAppName -- WTF???
set itemdel to comma
set the defaultFolder to myAppPath
/* Here's the beef: */
set the hideConsoleWindows to true
get shell("start" && myAppName && quote & theDocPath & quote)
set the defaultfolder to myOldDF
if it is empty then
/* The following line is for demonstration & may be commented: */
answer information "Done. You see, I responded before you closed the app!" titled "Info:"
exit LaunchWith
end if
/* In case something went wrong ... */
answer error "This shell call didn't work:" & CR & \
"start" && myAppName && quote & theDocPath & quote & CR & \
"in dir: " & myAppPath & CR & \
"Result: " & it titled "Error:"
end LaunchWith
Code: Select all
Launchwith "D:/myDir/myFile.txt","D:/myDir/myApp.exe"
Bonus bug: If the itemDel = slash, item -1 of a list may start with it ;-)
Have fun!
Edit: changed "function" to the correct "command" in the "Workaround" subtitle ...