HelpExec

Description

I wrote HelpExec so that I can run some Tcl scripts on my PC. True, after you install Tcl for windows, you can just click on the Tcl (.tcl) file icon to run the script... but it doesn't always work that way... for example, I want to be able to view text files by right clicking on their icons and choose "Send To" to view them with my editor (www.geocities.com/captain_lion/tedit/), which is a Tcl/Tk script. I cannot put tedit.tcl (my script) in windows/sendto directory directly -- because Windows' "Send To" won't invoke my the Tcl interpreter in that case! How does HelpExec help? I creat a directory, call it c:\TEditWin (or whatever), inside which I put HelpExec.exe and another file called cmdline.txt. cmdline.txt has only one line of text, which is

  COMMANDLINE "c:/tcl/bin/wish.exe" -f "c:/programs/tcl/tedit/tedit/tcl"
Then I put a link to c:/teditwin/helpwin.exe at windows/sendto directory, and call it TEdit... Voi la! Whenever I "send to" a file to TEdit, HelpExec.exe passes the target file to my editor script! Okay, here is how it works When HelpExec is excuted, it looks for a file called cmdline.txt in the same directory. It parses the file and execute whatever the file tells it to. The file cmdline.txt is only a text file where each line takes the format of

  <directive> <argument> [<argument> ...]
where directive is one of COMMANDLINE, DIRECTORY or WAIT, case sensitive, described as follow:
  • The COMMANDLINE directive tells HelpExec what to execute. HelpExec takes this line, appends whatever argument(s) is/are passed to HelpExec, and executes the line as a windows command line.
  • The DIRECTORY directive tells HelpExec what directory to execute the command line
  • The WAIT directive takes one argument, which is either 0 or 1. 0 signifies HelpExec should not wait for the spawned program to be input idle before it exits, 1 signifies otherwise.
In my above example, if I "send to" a file called myfile.txt, here is what will happen:
  • Windows calls the link file TEdit, which actually is HelpExec.exe, with the argument /myfile.txt
  • HelpExec looks up cmdline.txt, finds and parses the command line, then appends /myfile.txt to it, and executes, hence the command executed is something like
    
      "c:/tcl/bin/wish.exe" -f "c:/programs/tcl/tedit/tedit/tcl" /myfile.txt
    
  • wish.exe (in fact, Tcl interpreter) is run, which takes the 3 arguments -f, "c:/programs/tcl/tedit/tedit/tcl", and /myfile.txt and starts.
  • What comes up is the editor, TEdit, which the file myfile.txt (don't worry about it if you don't know how scripts work).
Just remember, HelpExec knows what command to execute by reading the command line from the file called "cmdline.txt", which has to reside in the same directory as HelpExec. That means, if you want two HelpExec running two different commands, you need to put them at seperate directories so that they can have seperate cmdline.txt files.

Feature

Enough about Tcl... it works with everything... It's useful when there is a file that Windows is going to execute, but is not an executable... say you want a command executed whenever Windows goes idle. You can do this by renaming HelpExec.exe to HelpExec.scr and install as screen saver... and then in the same directory, create a cmdline.txt and specify the command line you want (remember to use the COMMANDLINE keyword).

Also see the cmdline.txt that comes with the distribution for more info.

Where To Get

Click
here to get.




Click here to return to Mark Ng's home page. 1