Version 2 of Windows SDX Shell Fix

Updated 2003-06-07 04:12:39

WSF - Windows Shell fix

http://www.zipguy.net/wfs/wfs_rc.jpg

The Zipguy 06/06/2003 zipguy @ nonags dot com


Normally, on Windows, along with with a new file extension, you get a new file type and actions for that type which appear in the right click context menu. So for a Starkit's .kit extension, actions like "wrap", "unwrap","list", "update" etc. would be natural.

In windows this is accomplished by creating a new "File Type" of "Kit file" and associating the extension ".kit with that "File Type". Then new actions are added along with commands to perform those operation. At the end of the command for a given action a %1 or "%1" is placed and and windows will replace that with the fully qualified name (drive:\path...\filename.ext) of the file which was right clicked.

Unfortunately if one tries to do this using sdx.kit it fails, because the path separator in Windows "\" is the escape character to TCL so it mangles the filename badly. Things get very ugly if a subdirectory starts with "t" (tab) or "n" (to name a few characters) which get interpreted as "tab" and "return" respectively.


This is one of the annoyances with using SDX on Windows that WFS fixes. Since Windows will set the path to the folder which contains the file before invoking the command, simply doing a

    set lastparm [file tail [lindex $argv end] ] 

and then a

   set argv     [lreplace $argv end end $lastparm]

or combined

   set argv     [lreplace $argv end end [file tail [lindex $argv end] ] ]

and then passing control to sdx.kit would suffice to fix the problem

So if a file named rightclicked.kit (thought it was going to be foo.kit didn't you) were right clicked upon and an "Unwrap"command choosen that was defined as

"<path>tclkit-win32.upx.exe" "<path>sdx.kit" unwrap "%1"

tclkit would get called with the parameters

<path>sdx.kit unwrap <path>fileclicked.kit

This would fail for the reasons given above.


wsf.kit is a drop-in front-end for sdx.kit so if you change the command to

"<path>tclkit-win32.upx.exe" "<path>sdx.kit" unwrap "%1"

wsf will remove the path from the filename.

NOTE: wsf.kit must be in the same folder as sdx.kit. Tclkit can be anywhere.


Since adding a "File Type" with an "Associated Extension" and adding "Actions" and defining "Commands" is a seldom trodden path for far too many Windows users because Windows installers usually do this for them, this is a terrritory where too many Windows users rarely tread. Consequently, it is also an area which they are unfamilar with and quite likely to make mistakes.

Consider also that these are exactly the people that we would like to make successful, and precisely at this time since they probably just got excited about tcl, tclkit, starkits, have downloaded tclkit and sdx, and want an easy way to be able to unwrap that neat little application and look at the code. This would be an awful time to have them get frustrated by this thrashing around with Windows nonsense.

For these reasons, instead of just keeping wsf very simple, it tries to be very forgiving and notice and detect errors that they may have made, and give them helpful error messages.

wsf:

  • receives the parameters
  • adjusts the last one which has the <path>filename.ext so that it just has filename.ext
  • calls sdx passing the parameters

It also checks to make sure:

  • it's running under Windows
  • the last parameter is a filespec
  • the file exists (gives error if not)
  • that sdx.kit exists in the same folder as wsf.kit

'Orphan Processes' There is another potential problem that wsf.kit addresses. sdx.kit runs in a console and gives messages. When it's finished the savy tcl user would know to:

  • hit enter to get a prompt
  • and type in exit to end that session.

These excited TCL newbies would read the success messages and most likely almost all of them would just close the window, which leaves the tclkit running. This can lead to all kinds of problems with memory and in-use files further down the road. If one just closes the console, you need to Ctrl-Alt-Delete and cancel the zombie tasks to free things up.... Not good.

To solve this situation, after all the edits, just before the call to sdx.kit, wsf creates a small window with only an exit button so that it's obvious that something is running, and provides them with an easy way to end the task.

Unfortunately, sdx.kit does a

    wm withdraw .

so wsf.kit does an

    after 500 wm deiconify .

after sdx runs.

http://www.zipguy.net/wfs/wfs_exit.jpg

Great care was taken to avoid having to modify sdx.kit and design wsf.kit to be easy to use, mistake tolerant, and informative er.. verbose. As a result it is probably large considering the small role it really plays.

As this is the ZipGuy's first starkit it probably has lots of room for improvement and better coding by those more knowledgeable and smarter. At least it works and meets the intended goals. So comments and constructive criticism are very welcome.

'Defining the .kit "File Type" and sdx er- wsf "Actions"'

Adding the "Kit File" File Type

From Windows explorer: (Windows ME)

  1. select "Tools">"Folder" Options from the menu
  2. select the "File Types" tab
  3. click the new button under the "File Types" list
  4. put ".kit" in the "File Extension" field
  5. click ok

Adding Actions to the "Kit File"

  1. if necessary, from Windows Explorer select "Tools">"Folder" Options from the menu and then the "File Types" tab
  2. click on the "KIT" file Type
  3. click on the "Advanced" Button near the bottom
  4. in the "Edit File Type" dialog box, click on the "New" button to the right of the "Actions" listbox.

Enter any/all of the following actions one at a time.

  Action    Command
  -----------------------------------------------------
  List    "<path>tclkit-win32.upx.exe" "<path>wsf.kit" lsk    "%1"
  UnWrap  "<path>tclkit-win32.upx.exe" "<path>wsf.kit" unwrap "%1"
  Update  "<path>tclkit-win32.upx.exe" "<path>wsf.kit" update "%1"
  Wrap    "<path>tclkit-win32.upx.exe" "<path>wsf.kit" wrap   "%1"

Where <path> is the fully qualified path to the file. You can use the browse button for the tclkit file.

Then make sure that you put sdx.kit in the same folder as wsf.kit.

By fully qualifying the tclkit and wsf files you can use these commands on a file in any folder on your Windows partitions.

wfs is released as a Starkit at http://www.zipguy.net/wfs/wfs.kit


 By The ZipGuy     email: zipguy @ nonags dot com
                 website: http://www.zipguy.net
                Free PDF: http://www.freepdf.zipguy.net

  This is released to the public Domain as is with no warranty.
  Use this code completely at your own risk.