WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

FileMenu

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Adding Windows Filetype Command to Right-Click Menu

Keywords: 	 Adding Windows Filetype command  filemenu

Question:

In Windows, I want to add a new right-click, context-sensitive menu item to a filetype (*.HTM). In Windows' "Editing action for type: HTML document" dialog box, the Action: field reads "Get Full URL". The "Application used to perform action:" field reads "C:\Winbatch\MyWBTs\URLfget.exe" "%1".

The question is how do I pass the fully-qualified filename (%1) to my compiled WBT routine?

The ultimate goal is be able to copy the HTML file's URL to the Windows Clipboard, which I can do all day long using a customized WinBatch MNW file, but want to distribute this compiled routine to others who do not have WinBatch installed. As it stands, here's what the originating WBT looks like:

a=FileItemPath("")
a=ItemSortNC(a,@TAB)
a=StrReplace(a,@TAB,@CRLF)
a=StrReplace(a,"\","/")
a=StrReplace(a,"R:/EIA","http://eia.rose.xyz.com")
ClipPut(a)
Display(2,"Full path filenames placed on Clipboard",a)

Answer:

Here is a combo doit and installit routine. The installit part may need to be run with admin access.

Basically run it once by double-clicking the exe to have it self install.

And it only does one file at a time

NB: Script MUST be compiled

If RtStatus()!=1
   Message("Sorry","Script must be compiled")
   Exit
EndIf

;a) See if installed
htmlpointer=RegQueryValue(@REGCLASSES,".htm")
key=StrCat(htmlpointer,"\shell\GetFullUrl")
key2=StrCat(key,"\command")
Installed=@TRUE
moi=WinExename("")
cmdline=StrCat('"',moi,'" "%%1"')
If RegExistKey(@REGCLASSES,key2)==@FALSE
    Installed=@FALSE  ; hmmm not installed
Else
   If RegExistValue(@REGCLASSES,key2)==@FALSE
      Installed=@FALSE
   Else
      If RegQueryValue(@REGCLASSES,StrCat(key2,"\")) != cmdline Then Installed=@FALSE
   EndIf
EndIf

If Installed==@FALSE
   ErrorMode(@OFF)
      RegSetvalue(@REGCLASSES,key,"&Get full URL")
      RegSetvalue(@REGCLASSES,key2,cmdline)
   ErrorMode(@CANCEL)
   Installed=@TRUE

   If RegExistKey(@REGCLASSES,key2)==@FALSE
       Installed=@FALSE  ; hmmm not installed
   Else
      If RegExistValue(@REGCLASSES,key2)==@FALSE
         Installed=@FALSE
      Else
         If RegQueryValue(@REGCLASSES,StrCat(key2,"\")) != cmdline Then Installed=@FALSE
      EndIf
   EndIf

   If Installed==@FALSE
      Message("Sorry","Not properly installed.  Need admin access")
      Exit
   Else
      Message("GetFullUrl","Has been installed")
      Exit
   EndIf
EndIf

a=param1
a=StrReplace(a,"\","/")
a=StrReplace(a,"R:/EIA","http://eia.rose.xyz.com")
ClipPut(a)
Display(2,"Full path filename placed on Clipboard",a)

Article ID:   W15498
File Created: 2003:05:13:11:28:18
Last Updated: 2003:05:13:11:28:18