			editor = "winbatch studio.exe"    ;Default editor
			
			; Common menu for all file types
			
			; First figure out where filemenu.dll is installed via registry lookup
			RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems
			ErrorMode( @OFF )
			wbdir = RegQueryStr( @REGMACHINE, "SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion" )
			if wbdir == 0 
			 wbdir = RegQueryStr( @REGMACHINE, "SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion" )
			endif
			ErrorMode( @CANCEL )
			RegOpenFlags( 0 ) ; Tell WB to resume default registry operations
			if wbdir == 0 then Display( 5, "Error", "Registry entries missing.  Re-install WinBatch" )        
			
			; Initialize variables
			homedir = wbdir : "System\" 
			appdatadir = ShortCutDir( "AppData", 0, 1 ) : 'WinBatch\Settings\'
			subkey = 'Software\Wilson WindowWare\Settings\FileMenu\Menus'
			commonmenu = "FileMenu for all filetypes.mnw"

Two Explorers, side by side
			if WinVersion(5) >= "2-6-0"
				winclass = "CabinetWClass"
				classcode = 1
			else
				winclass = "ExploreWClass"
				classcode = 0
			endif
			dir = FilePath ( FileItemPath( "" ) )
			a = IntControl( 31, classcode, 0, 0, 0 )  ;return list of ids of explorer windows
			c = ItemCount( a, @TAB )
			switch c
				case 0
					ShellExecute( 'filemenu.exe',  '/separate,/e,C:\',  DirGet(), @Normal ,   '' )
					while FindWindow( winclass ) == ""    ;wait for it to come up
					TimeDelay( 0.1 )
					endwhile
					;Fall into case 1
				case 1
					TimeDelay( 0.3 )
					ShellExecute( 'filemenu.exe',  '/separate,/e,C:\',  DirGet(), @Normal ,   '' )
					break
				case c       ; 2 or more
					break
			endswitch
			TimeDelay( 0.5 )
			d = 1
			while c < 2 && d < 500
				TimeDelay( 0.1 )
				a = IntControl( 31, classcode, 0, 0, 0 )
				c = ItemCount( a, @TAB )
				d = d + 1
			endwhile
			if c<2 then exit
			id1 = ItemExtract( 1, a, @TAB)
			id2 = ItemExtract( 2, a, @TAB)
			WinPlaceSet( @NORMAL, id2, "500 0 1000 900" )
			WinShow( id2 )
			WinActivate( id2 )
			TimeDelay( 0.2 )
			WinPlaceSet( @NORMAL, id1, "0 0 500 900" )
			WinShow( id1 )    
			WinActivate( id1 )

Open Other ... ; Choose an application to view or edit the selected file. 
 &Browser (binary file viewer)  ; View any file in binary format.
        highlighted_files = FileItemPath ( "" )
        fc = ItemCount ( highlighted_files , @TAB )
        for j = 1 to fc
           file = ItemExtract ( j , highlighted_files , @TAB )
           if !FileExist ( file )
              file = ""
           else 
              if FileExtension ( file ) == "" then file =  file : "." 
           endif
			  ShellExecute( "browser.exe", '"' : file : '"', '', @NORMAL, '' )
        next 

 &Notepad  ; Modify small plain text files.
        highlighted_files = FileItemPath ( "" )
        fc = ItemCount ( highlighted_files , @TAB )
        for j = 1 to fc
           file = ItemExtract ( j , highlighted_files , @TAB )
           If !FileExist ( file )
              file = ""
           else 
              If FileExtension ( file ) == "" then file =  file : "." 
           endif
           ShellExecute( "notepad.exe", '"' : file : '"', '', @NORMAL, '' )
        next
 
 &MSPaint (bitmap) ; View and Modify bitmaps
        mspaintexe = FileLocate ( "mspaint.exe" )
        if mspaintexe == ""
            rname="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MSPAINT.EXE" 
            mspaintexe = RegQueryStr ( @REGMACHINE , rname )
         endif
         highlighted_files = FileItemPath ( "" )
         fc = ItemCount ( highlighted_files , @TAB )
         for j = 1 to fc
            file = ItemExtract ( j , highlighted_files , @TAB )
            bmpfile = StrLower ( FileExtension ( file ) )
            if bmpfile != "bmp" && bmpfile != "jpg" && bmpfile != "gif" && bmpfile != "jpeg"
              Message( "Error: Not an image file", file : @CRLF : "Select a bmp, gif or jpg file and try again." )
              continue
            endif
            ShellExecute( mspaintexe, '"' : file : '"', '', @NORMAL, '' )
         next

 &Wordpad (text and graphics) ; Modify WORD, RTF, plain text files. Can contain bitmaps, too.
        wordpadexe = FileLocate ( "wordpad.exe" )
        if wordpadexe == ""
            rname = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WORDPAD.EXE" 
            wordpadexe = RegQueryStr ( @REGMACHINE , rname )
         endif
         highlighted_files = FileItemPath ( "" )
         fc = ItemCount ( highlighted_files , @TAB )
         for j = 1 to fc
            file = ItemExtract ( j , highlighted_files , @TAB )
            if !( FileExist( file ) ) then file = ""
               else if FileExtension(file) == "" then file = StrCat(file, ".")
            ShellExecute( wordpadexe, '"' : file : '"', '', @NORMAL, '' )
         next

 WinBatch &Studio (text) ; Open file with WinBatch Studio
        highlighted_files = FileItemPath ( "" )
        fc = ItemCount ( highlighted_files , @tab )
        for j = 1 to fc
           file = ItemExtract ( j , highlighted_files , @tab )
			  ShellExecute( editor, '"' : file : '"', DirGet(), @NORMAL, "")
        next
     
File Operations
 File/Folder size    ;Sum sizes of all highlighted files and folders
        ;Note: Some shell or file manager applications using the WIL Interpreter allow an empty string ("") 
        ;to be used as the "file-list" parameter, in which case all files highlighted in the file display 
        ;are returned. However, if there are any file names or wildcards in the string, all files matching 
        ;the file names are returned, regardless of which ones are 
        tot = FileSize( FileItemize( "" ) )
        sub1 = DirItemize("")
        totdir = 0
        level = 1
        dir1 = DirGet()      
        numdir1 = ItemCount( sub1, @TAB )
        index1 = 0
  
        :dsloop
        If index%level% == numdir%level% then Goto upalevel
        index%level% = index%level% + 1
		  dir = dir%level% : ItemExtract( index%level%, sub%level%, @TAB )
        DirChange(dir)
        
        totdir = totdir+1
        tot = tot + FileSize( FileItemize("*") )
        level = level + 1
        dir%level% = DirGet( )
        sub%level% = DirItemize( "*" )
        numdir%level% = ItemCount( sub%level%, @TAB )
        index%level% = 0
        goto dsloop
  
        :upalevel
        drop( dir%level%,sub%level%, index%level%, numdir%level% )
        level = level - 1
        if level != 0 then goto dsloop
 
        ; -----------
        ; Termination
        ; -----------        
        If StrLen( tot ) < 9 then tot = StrFill( "", 9 - StrLen( tot ) ) : tot
        tot = StrSub( tot, 1, 3 ) : "," : StrSub( tot, 4, 3 ) : "," : StrSub( tot, 7, 3 )
        tot = StrTrim( tot )
        If StrSub( tot, 1, 1 ) == "," then tot = StrSub( tot, 2, StrLen(tot) - 1 )
        tot = StrTrim( tot )
        if StrSub( tot, 1, 1 ) == "," then tot = StrSub( tot, 2, StrLen(tot) - 1 )
        tot = StrTrim( tot )
        Message( totdir:" Subdirectories included", "Total size ":tot:" bytes." )

 Print (with Notepad)   ;Print text-type file with notepad on default printer
        highlighted_files = FileItemPath ( "" )
        fc = ItemCount ( highlighted_files , @TAB )
        for j = 1 to fc
           file = ItemExtract ( j , highlighted_files , @TAB )
           if !FileExist ( file )
              continue
           else 
              If FileExtension ( file ) == "" then file = StrCat ( file , "." )
           endif
			  ShellExecute('notepad.exe', '/p "' : file : '"', '', @NORMAL, '' )
        next 

 Associate              ;Associate this type of file with an application
		ext = StrLower( FileExtension( CurrentFile() ) )
		Terminate(( ext == "exe" || ext == "com" || ext == "bat" || ext == "pif" || ext == "lnk" || ext == "cmd" ), "Ooops", "Cannot associate executable files" )
		if RegExistKey( @REGCLASSES,"." : ext)
			ans = AskYesNo( 'File Association: !!Use at your own risk!!', 'This file extension has a previously defined file association. It is recommended that you backup your registry before continuing.  Are you sure that you want to remove this registry key? ' )
			if ans == @no then exit
		endif
		exe = AskFileName( "Associate " : ext : " files with","C:\", "Executable Files|*.exe;*.com;*.bat;*.pif;*.cmd|All Files|*.*|", "", 1 )
		rkey = RegOpenKey( @REGCLASSES,"" )
		ErrorMode( @OFF )
		RegDeleteKey( rkey,"." : ext )
		ErrorMode( @CANCEL )
		RegSetValue( rkey, "." : ext, ext : "_auto_file" )
		RegSetValue( rkey,ext : "_auto_file\shell\open\command", strcat( '"', exe, '" "%%1"' ) )
		AU=StrUpper( ext )
		RegSetValue( rkey, ext : "_auto_file", AU : " File" )

 File Attributes        ;View file attributes
		highlighted_files = FileItemize( "" )
		numfiles = ItemCount( highlighted_files, @TAB )
		while numfiles == 1
			file = CurrentFile( )
			result = FileAttrGet( file )
			if StrLen( file ) > 30
				fileindialog = StrSub( file, 1, 30)			
				fileindialog = StrCat( fileindialog, " ..." )
			else 
				fileindialog = file
			endIf
			
			readonly = 2
			archive = 2
			system = 2
			hidden = 2
			if StrSub( result, 1, 1 ) == "R" then readonly = "3"
			if StrSub( result, 2, 1 ) == "A" then archive = "3"
			if StrSub( result, 3, 1 ) == "S" then system = "3"
			if StrSub( result, 4, 1 ) == "H" then hidden = "3"
			
			FileAttributesFormat=`WWWDLGED,6.2`
			
			FileAttributesCaption=`File Attributes`
			FileAttributesX=007
			FileAttributesY=025
			FileAttributesWidth=198
			FileAttributesHeight=100
			FileAttributesNumControls=017
			FileAttributesProcedure=`DEFAULT`
			FileAttributesFont=`DEFAULT`
			FileAttributesTextColor=`DEFAULT`
			FileAttributesBackground=`DEFAULT,DEFAULT`
			FileAttributesConfig=0
			
			FileAttributes001=`111,085,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"&Cancel",0,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes002=`043,019,038,012,STATICTEXT,"StaticText_1",DEFAULT,"Read Only",DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes003=`127,019,036,012,STATICTEXT,"StaticText_System",DEFAULT,"System",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes004=`085,019,036,012,STATICTEXT,"StaticText_Archive",DEFAULT,"Archive",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes005=`157,019,036,012,STATICTEXT,"StaticText_Hidden",DEFAULT,"Hidden",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes006=`057,085,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"&OK",1,60,32,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes007=`003,055,036,012,STATICTEXT,"StaticText_On",DEFAULT,"On",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes008=`003,037,036,012,STATICTEXT,"StaticText_Off",DEFAULT,"Off",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes009=`001,005,194,012,STATICTEXT,"StaticText_7",DEFAULT,"Set File Attributes for => `:fileindialog:`",DEFAULT,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes010=`043,037,036,012,RADIOBUTTON,"RadioButton_1",readonly,DEFAULT,2,100,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes011=`043,055,036,012,RADIOBUTTON,"RadioButton_2",readonly,DEFAULT,3,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes012=`157,055,036,012,RADIOBUTTON,"RadioButton_3",hidden,DEFAULT,3,120,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes013=`085,037,036,012,RADIOBUTTON,"RadioButton_4",archive,DEFAULT,2,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes014=`085,055,036,012,RADIOBUTTON,"RadioButton_5",archive,DEFAULT,3,140,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes015=`157,037,036,012,RADIOBUTTON,"RadioButton_6",hidden,DEFAULT,2,150,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes016=`127,037,036,012,RADIOBUTTON,"RadioButton_7",system,DEFAULT,2,160,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			FileAttributes017=`127,055,036,012,RADIOBUTTON,"RadioButton_8",system,DEFAULT,3,170,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
			
			ButtonPushed = Dialog( "FileAttributes" )
			
			switch buttonpushed			
			   case 0
			        Break
			        
			   case 1
					  first = ""
			        second = ""
			        third = ""
			        fourth = ""
			        if readonly == 2 then first = "r"
			        if archive == 2 then second = "a"
			        if system == 2 then third = "s"
			        if hidden == 2 then fourth = "h"
			        if readonly == 3 then first = "R"
			        if archive == 3 then second = "A"
			        if system == 3 then third = "S"
			        if hidden == 3 then fourth = "H"			
			        attributes = StrCat( first, second, third, fourth )
			        FileAttrSet( file, attributes )
			        break
			endswitch			    			
			exit
		endWhile
		
		;Set Attributes: Selected Files		
		displayfiles = highlighted_files
		readonly = 1
		archive = 1
		system = 1
		hidden = 1

		AttribFormat=`WWWDLGED,6.2`
		
		AttribCaption=`Attributes`
		AttribX=006
		AttribY=025
		AttribWidth=226
		AttribHeight=108
		AttribNumControls=022
		AttribProcedure=`DEFAULT`
		AttribFont=`DEFAULT`
		AttribTextColor=`DEFAULT`
		AttribBackground=`DEFAULT,DEFAULT`
		AttribConfig=0
		
		Attrib001=`111,085,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"&Cancel",0,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib002=`043,019,038,012,STATICTEXT,"StaticText_1",DEFAULT,"Read Only",DEFAULT,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib003=`127,019,036,012,STATICTEXT,"StaticText_System",DEFAULT,"System",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib004=`085,019,036,012,STATICTEXT,"StaticText_Archive",DEFAULT,"Archive",DEFAULT,40,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib005=`167,019,036,012,STATICTEXT,"StaticText_Hidden",DEFAULT,"Hidden",DEFAULT,50,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib006=`003,035,038,012,STATICTEXT,"StaticText_5",DEFAULT,"No Change",DEFAULT,60,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib007=`003,071,036,012,STATICTEXT,"StaticText_On",DEFAULT,"On",DEFAULT,70,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib008=`003,053,036,012,STATICTEXT,"StaticText_Off",DEFAULT,"Off",DEFAULT,80,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib009=`043,035,036,012,RADIOBUTTON,"RadioButton_1",readonly,DEFAULT,1,90,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib010=`043,053,036,012,RADIOBUTTON,"RadioButton_2",readonly,DEFAULT,2,100,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib011=`043,071,036,012,RADIOBUTTON,"RadioButton_3",readonly,DEFAULT,3,110,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib012=`085,035,036,012,RADIOBUTTON,"RadioButton_4",archive,DEFAULT,1,120,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib013=`085,053,036,012,RADIOBUTTON,"RadioButton_5",archive,DEFAULT,2,130,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib014=`085,071,036,012,RADIOBUTTON,"RadioButton_6",archive,DEFAULT,3,140,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib015=`127,035,036,012,RADIOBUTTON,"RadioButton_7",system,DEFAULT,1,150,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib016=`127,053,036,012,RADIOBUTTON,"RadioButton_8",system,DEFAULT,2,160,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib017=`127,071,036,012,RADIOBUTTON,"RadioButton_9",system,DEFAULT,3,170,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib018=`167,035,036,012,RADIOBUTTON,"RadioButton_10",hidden,DEFAULT,1,180,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib019=`167,053,036,012,RADIOBUTTON,"RadioButton_11",hidden,DEFAULT,2,190,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib020=`167,071,036,012,RADIOBUTTON,"RadioButton_12",hidden,DEFAULT,3,200,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib021=`059,003,130,012,STATICTEXT,"StaticText_8",DEFAULT,"Set Attributes for Selected Files",DEFAULT,210,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
		Attrib022=`057,085,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"&OK",1,220,32,DEFAULT,DEFAULT,DEFAULT`
		
		ButtonPushed=Dialog("Attrib")
		
		switch buttonpushed	
		   case 0
		        Break
		        
		   case 1		
		        first = ""
		        second = ""
		        third = ""
		        fourth = ""
		        If readonly == 2 then first = "r"
		        If archive == 2 then second = "a"
		        If system == 2 then third = "s"
		        If hidden == 2 then fourth = "h"
		        If readonly == 3 then first = "R"
		        if archive == 3 then second = "A"
		        if system == 3 then third = "S"
		        if hidden == 3 then fourth = "H" 
		        attributes = StrCat( first, second, third, fourth )
		        FileAttrSet(highlighted_files, attributes)
		        break
		endswitch
		Exit                              

 DOS &Copy  ; Like the good, old, DOS COPY command.
       highlighted_files = StrTrim( FileItemize("") )
       highlighted_files = StrReplace( highlighted_files, @TAB, "|" )
       if highlighted_files == "" then Message( "Copy Error", "No files selected" )
       then Exit
       if ItemCount( highlighted_files, "|" ) == 1 then t = highlighted_files
       else t = ""
       t = AskLine( "Copy", StrCat( highlighted_files, @CRLF, @CRLF, "to" ), t )
       if t == "" then Message( "Copy Error", "Cannot copy to null file name" )
       then Exit
       FileCopy( highlighted_files, t, @TRUE )

 DOS &Rename  ;Like the good, old DOS RENAME command.
       highlighted_files = StrTrim( FileItemize( "" ) )
       highlighted_files = StrReplace( highlighted_files, @TAB, "|" )
       if highlighted_files == "" then Message( "Rename Error", "No files selected" )
       then Exit
       if ItemCount( highlighted_files, "|" ) == 1 then t = highlighted_files
       else t = ""
       t = AskLine( "Rename", StrCat(highlighted_files, @CRLF, @CRLF, "to"), t )
       if t == "" then Message( "Rename Error", "Cannot rename to null file name" )
       then Exit
       FileRename( highlighted_files, t )
  
Clipboard Tricks ; Copies just the filenames to the clipboard
 FileName(s) to Clipboard ; Just the filenames
        for xx = 1 to 5
           highlighted_files = FileItemize( "" )
           if highlighted_files != "" then break
           TimeDelay( 1 )
         next
         if highlighted_files==""
            Message( "Error", "Filenames not placed on clipboard" )
         else
            highlighted_files = ItemSortNC( highlighted_files, @TAB )
            highlighted_files = StrReplace( highlighted_files, @TAB, @CRLF )
            ClipPut( highlighted_files )
            Display( 2,"File names placed on Clipboard", highlighted_files )
         endif

 Path and FileName(s) to Clipboard ; Copies filenames with full paths to the Clipboard
        for xx = 1 to 5
           highlighted_files = FileItemPath( "" )
           if highlighted_files != "" then break
           TimeDelay( 1 )
         next
         if highlighted_files == ""
            Message( "Error", "Filenames not placed on clipboard" )
         else
            highlighted_files = ItemSortNC(highlighted_files, @TAB )
            highlighted_files = StrReplace(highlighted_files, @TAB, @CRLF )
            ClipPut( highlighted_files )
            Display( 2, "Full path file names placed on Clipboard", highlighted_files )
         endif

 Path to Clipboard   ; Copies just the path to the clipboard
        for xx = 1 to 5
           path = CurrentPath()
           if path != "" then break
           TimeDelay( 1 )
         next
         if path == ""
            Message( "Error", "Path not placed on clipboard" )
         else
            ClipPut( path )
            Display( 2, "Path placed on Clipboard", path )
         endif         
        
 _Run Clipboard Viewer   ; Lets you see what is on the clipboard
      file = "clipbrd.exe"
 	   viewer = FileLocate( file )  ;Modified for Vista
		if viewer != ""
			ShellExecute( viewer, '', '', @NORMAL, '' )
  	   else
			Message( "Notice", "Clipboard not available on this Windows platform" )
		endif

Command Prompt Here
     cmdexe = Environment( "COMSPEC" )
     a = DirGet()
	  ShellExecute( cmdexe, '', a, @NORMAL, '' )

WIL Interactive
 Execute a function
        Call( "%homedir%wwwmenu95.wil", "CMDSTACK NEWCMD" )

 _Load Consolidated WIL help file
		  ShellExecute( 'WILHH.EXE', '"' : wbdir : 'ConsolidatedWIL.chm" "" $global_main', '', @NORMAL, '' ) 
     
_Edit File Menus ; Modify WinBatch FileMenus here 
 Edit menu for this filetype  ; Edit menus for files with a specific file extension.
        ext = StrUpper( FileExtension( CurrentFile() ) )
		  if ext == '' then  ext = '.' ; handle files with no extension
		  ;Read registry for value
		  RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems
		  ;ret = RegExistKey( @REGCURRENT, subkey : '[' : ext : ']' )
		  ret = RegExistValue( @REGCURRENT, subkey : '[' : ext : ']' )
		  if ret
		  	mnw = RegQueryStr( @REGCURRENT, subkey : '[' : ext : ']' )
		  else
 		   if ext == '.' then mnw = appdatadir : "FileMenu for no-extension files.mnw"
			else mnw = appdatadir : "FileMenu for " : ext : " files.mnw"
		  endif
		  RegOpenFlags( 0 ) ; Tell WB to resume default registry operations
		  
        if  FileExist( mnw )
                if ret == 0
					    RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems
						 RegSetValue( @REGCURRENT, subkey : '[' : ext : ']', mnw )
						 RegOpenFlags( 0 ) ; Tell WB to resume default registry operations
                   Display( 7, ext : " was missing in registry" , "Adding menu file back in now" )
                endif
        else
                c = AskYesNo( "Please note:", "The menu file for the %ext% filetype does not exist.  Would you like to start a new one?")
                if c == @NO then exit
                c =                  "; WinBatch FileMenu for %ext% filetype%@CRLF%"
                c = StrCat( c, @CRLF,"; This is a sample menu file to help you get started")
                c = StrCat( c, @CRLF,"; writing your very own Winbatch FileMenu menus.  It is")
                c = StrCat( c, @CRLF,"; really not too bad.  WinBatch is a simple programming")
                c = StrCat( c, @CRLF,"; language.  You can find out just about all you need to")
                c = StrCat( c, @CRLF,"; know from the Windows Interface Language help file or")
                c = StrCat( c, @CRLF,"; the manual.  Check out the section on Menu Files,")
                c = StrCat( c, @CRLF,"; the WIL Tutorial and the WIL Function Reference.")
					 c = StrCat( c, @CRLF)
                c = StrCat( c, @CRLF,"        ; Figure out Winbatch home directory")
                c = StrCat( c, @CRLF,'        RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems')
                c = StrCat( c, @CRLF,'        ErrorMode( @OFF )')
                c = StrCat( c, @CRLF,'        wbdir = RegQueryStr( @REGMACHINE, "SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion" )')
                c = StrCat( c, @CRLF,'        if wbdir == 0 ')
                c = StrCat( c, @CRLF,'           wbdir = RegQueryStr( @REGMACHINE, "SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion" )')
                c = StrCat( c, @CRLF,'        endif')
                c = StrCat( c, @CRLF,'        ErrorMode( @CANCEL )')
                c = StrCat( c, @CRLF,'        RegOpenFlags( 0 ) ; Tell WB to resume default registry operations')
                c = StrCat( c, @CRLF,'        if wbdir == 0 then Display( 5,"Error", "Registry entries missing.  Re-install WinBatch" )')
                c = StrCat( c, @CRLF,'        homedir = wbdir : "System\"')
					 c = StrCat( c, @CRLF)
					 c = StrCat( c, @CRLF,'        ; Initialize Variables')
					 c = StrCat( c, @CRLF,'        appdatadir = ShortCutDir( "AppData", 0, 1 ) : "WinBatch\Settings\"')
					 c = StrCat( c, @CRLF,'        subkey = "Software\Wilson WindowWare\Settings\FileMenu\Menus"')


                c = StrCat( c, @CRLF,@CRLF,'Standalone menu item            ; Sample menu item')
                c = StrCat( c, @CRLF,      '        Message( "Hello", "There" )')

                c = StrCat( c, @CRLF,@CRLF,'Top Level menu item')
                c = StrCat( c, @CRLF,      ' Selected File is               ; Shows currently selected file')
                c = StrCat( c, @CRLF,      '        a = CurrFilePath()')
                c = StrCat( c, @CRLF,      '        Message( "Selected File is", a )')
                c = StrCat( c, @CRLF,      ' Run Calculator                 ; Sample Run function')
					 c = StrCat( c, @CRLF,      '        a = CurrFilePath()')
                c = StrCat( c, @CRLF,      `        ShellExecute( 'calc.exe', '"':a:'"', '', @NORMAL, '' )`)
                c = StrCat( c, @CRLF,      ' Run Notepad on selected file   ; Sample Run function with filename')
                c = StrCat( c, @CRLF,      '        a = CurrFilePath()')
                c = StrCat( c, @CRLF,      `        ShellExecute( 'notepad.exe', '"':a:'"', '', @NORMAL, '' )`)

                c = StrCat( c, @CRLF,@CRLF,'; Note: You may want to delete this menu item if you edit this file')
                c = StrCat( c, @CRLF,      ' _Delete this sample menu file  ; Deletes this menu file')
					 c = StrCat( c, @CRLF,      '        ext = StrUpper( FileExtension( CurrentFile() ) )')
					 c = StrCat( c, @CRLF,      '        if ext == "" then  ext = "." ; handle files with no extension')
					 c = StrCat( c, @CRLF,      '        if ext == "." then mnw = appdatadir : "FileMenu for no-extension files.mnw"')
					 c = StrCat( c, @CRLF,      '        else mnw = appdatadir : "FileMenu for " : ext : " files.mnw"')
                c = StrCat( c, @CRLF,      '        c = AskYesNo("Are you sure you wish to delete this menu file",mnw)')
                c = StrCat( c, @CRLF,      '        if c == @YES')
					 c = StrCat( c, @CRLF,      '           RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems')
                c = StrCat( c, @CRLF,      '           RegDelValue( @REGCURRENT, subkey : "[" : ext : "]" )')
					 c = StrCat( c, @CRLF,      '           RegOpenFlags( 0 ) ; Tell WB to resume default registry operations')
					 c = StrCat( c, @CRLF,      '           FileDelete( mnw )')
                c = StrCat( c, @CRLF,      '        endif')
                c = StrCat( c, @CRLF)

                fh = FileOpen( mnw, "WRITE" )
                FileWrite( fh, c )
                FileClose( fh )
					 RegOpenFlags( 1 ) ; Tell WB to look at 32 bit registry on 64 bit systems
					 RegSetValue( @REGCURRENT, subkey : '[' : ext : ']', mnw )
					 RegOpenFlags( 0 ) ; Tell WB to resume default registry operations
                Drop( c )                
        endif
		  ShellExecute( editor, '"':mnw:'"', '', @NORMAL, '' )

 Edit menu for all filetypes      ; Edit global menu for all files 
        mnw = commonmenu
        if FilePath( mnw ) == "" then mnw = homedir : mnw
		  ShellExecute( editor, '"':mnw:'"', '', @NORMAL, '' )

 _Load Consolidated WIL help file
      ShellExecute( 'WILHH.EXE', '"' : wbdir : 'ConsolidatedWIL.chm" "" $global_main', '', @NORMAL, '' )

 _About WinBatch FileMenu  ; Software from Wilson WindowWare
        About()
           
