Hi Primes Users,
We’re back with another tech support challenge that we wanted to share with you!
A customer had been having issues launching Maplets using the standard double-clicking method. This is a known issue that rarely occurs, but is being addressed for a future release. In the meantime, we were able to provide this person with a command-prompt-based way of opening the Maplet, and we thought it would be great to share in case you run into the same kind of problem.
After suggesting a few workarounds, our Team Lead was able to offer a command-prompt based way of solving the problem. Since command prompts are the target of batch scripts, which we had already used as a workaround for another issue, we just needed a way of programmatically creating scripts based on the command prompt code for each file.
Using various commands from the FileTools package (including a technique suggested by our Team Lead), we were able to put together code that takes all files in a particular folder (namely, a folder named “Maplets” on the Desktop), and creates a new batch script from a template that is based on the command prompt code (provided that the template is saved in the same Maplets folder under the file name “Maplet script”):
restart; with(FileTools): username := kernelopts(username):
directory := cat("C:\\Users\\", username, "\\Desktop\\Maplets"):
dir := ListDirectory(directory): dir := Basename~(dir):
main := cat(directory, "\\Maplet script.txt"): body := Import(main):
n := numelems(dir):
for i to n do
script := cat(directory, "\\launch ", dir[i], ".txt");
batch := cat(directory, "\\launch ", dir[i], ".bat");
newbody := StringTools:-Substitute(body, "name", dir[i]);
if not "%minimized%"=="" goto :minimized
start /min cmd /C "%~dpnx0"
"C:\Program Files\Maple 2018\bin.X86_64_WINDOWS\mapletviewer.exe" "C:\Users\%USERNAME%\Desktop\Maplets\name.maplet"
Before using the Maplet script:
After using the Maplet script:
If the appropriate executable is referenced, and the relevant file paths are adjusted accordingly, one should be able to adapt this process to other programs and their corresponding files. In fact, any batch script that needs to be modified programmatically can be modified using these techniques. Does anyone have other useful batch scripts that they’ve modified programmatically in Maple using similar techniques?
*(including dragging the files to the executable directly, which only seemed to work when the executable was in its original directory)