right-click command question

  • Follow


Hi All
I have Creating a right-click command to backup file try txt and then
xls file.

Try txt file ok.
Then try xls file, not ok, when right-click no option prompted ? Do
you know why ?

For txt file
REGEDIT4
[HKEY_CLASSES_ROOT\txtfile\shell\backupfile]
@="Backup Text File"

[HKEY_CLASSES_ROOT\txtfile\shell\backupfile\command]
@="cscript //b  H:\Software\shell\xbcp.vbs "%1" "txt""

For excel file
REGEDIT4
[HKEY_CLASSES_ROOT\xlsfile\shell\backupfile]
@="Backup Excel File"

[HKEY_CLASSES_ROOT\xlsfile\shell\backupfile\command]
@="cscript //b  H:\Software\shell\xbcp.vbs "%1" "xls""

Option Explicit

'~~ xbcp.vbs
'~~ 2010/02/24

dim objArgs, iArg
Dim fso,fso1
dim fn,newfn
Dim wdate
dim fncnt
dim fnprefix
dim fnext

Set objArgs = WScript.Arguments

for iArg = 0 To objArgs.count - 1
   wscript.echo "Arguments=", objArgs(iArg)
   if iArg = 0 then
      fn = objArgs(iArg)
   end if
   if iArg = 1 then
      fnext = objArgs(iArg)
   end if
next

wscript.echo fn
wscript.echo fnext
fnprefix = mid(fn,1,instrrev(fn,fnext) - 2)
wscript.echo "fnprefix=" & fnprefix
Set fso = CreateObject("Scripting.FileSystemObject")

if fso.FileExists(fn) then
    wDate = Year(Now) & Right("00" & Month(Now), 2) & Right("00" &
Day(Now), 2)
    newfn = fnprefix & "_" & wdate & "." & fnext

    set fso1  = CreateObject("Scripting.FileSystemObject")

    fncnt = 0
    if fso1.FileExists(newfn) then
       while (fso1.FileExists(newfn))
           fncnt = fncnt + 1
           newfn = fnprefix & "_" & wdate & "_" & fncnt & "." & fnext
       wend
    end if

    fso.copyfile fn, newfn

end if

wscript.echo ("DONE")

'~~ WScript.Sleep
1000
0
Reply moonhkt 2/25/2010 2:37:30 PM

 I don't use MS Office, so I don't know what the
class keys look like, but I wonder if you might
be able to just set the value under HKCR\*, for
all files. Then your script can figure out what
kind of file it's dealing with.

> Hi All
> I have Creating a right-click command to backup file try txt and then
> xls file.
>
> Try txt file ok.
> Then try xls file, not ok, when right-click no option prompted ? Do
> you know why ?
>
> For txt file
> REGEDIT4
> [HKEY_CLASSES_ROOT\txtfile\shell\backupfile]
> @="Backup Text File"
>
> [HKEY_CLASSES_ROOT\txtfile\shell\backupfile\command]
> @="cscript file://b  H:\Software\shell\xbcp.vbs "%1" "txt""
>
> For excel file
> REGEDIT4
> [HKEY_CLASSES_ROOT\xlsfile\shell\backupfile]
> @="Backup Excel File"
>
> [HKEY_CLASSES_ROOT\xlsfile\shell\backupfile\command]
> @="cscript file://b  H:\Software\shell\xbcp.vbs "%1" "xls""
>
> Option Explicit
>
> '~~ xbcp.vbs
> '~~ 2010/02/24
>
> dim objArgs, iArg
> Dim fso,fso1
> dim fn,newfn
> Dim wdate
> dim fncnt
> dim fnprefix
> dim fnext
>
> Set objArgs = WScript.Arguments
>
> for iArg = 0 To objArgs.count - 1
>    wscript.echo "Arguments=", objArgs(iArg)
>    if iArg = 0 then
>       fn = objArgs(iArg)
>    end if
>    if iArg = 1 then
>       fnext = objArgs(iArg)
>    end if
> next
>
> wscript.echo fn
> wscript.echo fnext
> fnprefix = mid(fn,1,instrrev(fn,fnext) - 2)
> wscript.echo "fnprefix=" & fnprefix
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> if fso.FileExists(fn) then
>     wDate = Year(Now) & Right("00" & Month(Now), 2) & Right("00" &
> Day(Now), 2)
>     newfn = fnprefix & "_" & wdate & "." & fnext
>
>     set fso1  = CreateObject("Scripting.FileSystemObject")
>
>     fncnt = 0
>     if fso1.FileExists(newfn) then
>        while (fso1.FileExists(newfn))
>            fncnt = fncnt + 1
>            newfn = fnprefix & "_" & wdate & "_" & fncnt & "." & fnext
>        wend
>     end if
>
>     fso.copyfile fn, newfn
>
> end if
>
> wscript.echo ("DONE")
>
> '~~ WScript.Sleep
> 1000


0
Reply mayayana 2/25/2010 3:59:04 PM


moonhkt wrote:
> Then try xls file, not ok, when right-click no option prompted ? 
> Do you know why ?
> 

hi moonhkt,

I don't actually _know_ why, but I suspect that ms is not
handling the excel (xls) extension the same as the text (txt)
extension.  I suspect that ms has devised something far more
complicated.

On my system, there is no such thing as an "xlsfile" registry
entry.  Granted, my system is probably much older than yours
-- win98se.  fwiw, you will find listed below the registry
entries for (my) "standard" xls context menu options, i.e.,
new, open, print and printto.  If your registry looks anything
like mine, then that would be the place to start looking to
make your "backup" context menu addition.

--- <registry stuff> ---
[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8]
"EditFlags"=hex:00,00,01,00
@="Microsoft Excel Worksheet"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell]
@="Open"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\New]
@="&New"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\New\command]
"command"=hex(7):34,46,43,21,21,67,78,73,66,28,4e,67,5d,71,46,60,48,7b,4c,73,\
 
45,58,43,45,4c,46,69,6c,65,73,3e,78,6c,54,5d,6a,49,7b,6a,66,28,3d,31,26,4c,\
   5b,2d,38,31,2d,5d,20,2f,65,00,00
@="\"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE\" /e"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\New\ddeexec]
@="[new(\"%1\")]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\New\ddeexec\application]
@="Excel"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\New\ddeexec\topic]
@="system"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print]

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print\command]
"command"=hex(7):34,46,43,21,21,67,78,73,66,28,4e,67,5d,71,46,60,48,7b,4c,73,\
 
45,58,43,45,4c,46,69,6c,65,73,3e,78,6c,54,5d,6a,49,7b,6a,66,28,3d,31,26,4c,\
   5b,2d,38,31,2d,5d,20,2f,65,00,00
@="\"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE\" /e"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print\ddeexec]
@="[open(\"%1\")][print()][close()]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print\ddeexec\application]
@="Excel"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print\ddeexec\ifexec]
@="[open(\"%1\")][print()][quit()]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Print\ddeexec\topic]
@="system"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto]

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto\command]
"command"=hex(7):34,46,43,21,21,67,78,73,66,28,4e,67,5d,71,46,60,48,7b,4c,73,\
 
45,58,43,45,4c,46,69,6c,65,73,3e,78,6c,54,5d,6a,49,7b,6a,66,28,3d,31,26,4c,\
   5b,2d,38,31,2d,5d,20,2f,65,00,00
@="\"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE\" /e"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto\ddeexec]
@="[open(\"%1\")][print(1,,,,,,,,,,,2,\"%2\")][close()]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto\ddeexec\application]
@="Excel"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto\ddeexec\ifexec]
@="[open(\"%1\")][print(1,,,,,,,,,,,2,\"%2\")][quit()]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Printto\ddeexec\topic]
@="system"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Open]

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Open\command]
"command"=hex(7):34,46,43,21,21,67,78,73,66,28,4e,67,5d,71,46,60,48,7b,4c,73,\
 
45,58,43,45,4c,46,69,6c,65,73,3e,78,6c,54,5d,6a,49,7b,6a,66,28,3d,31,26,4c,\
   5b,2d,38,31,2d,5d,20,2f,65,00,00
@="\"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE\" /e"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Open\ddeexec]
@="[open(\"%1\")]"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Open\ddeexec\application]
@="Excel"

[HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8\shell\Open\ddeexec\topic]
@="system"

--- </registry stuff> ---

cheers, jw
____________________________________________________________

You got questions?  WE GOT ANSWERS!!!  ..(but, no guarantee
    the answers will be applicable to the questions)

0
Reply mr_unreliable 2/25/2010 9:51:00 PM

"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message 
news:u0BGkRmtKHA.6140@TK2MSFTNGP05.phx.gbl...
> moonhkt wrote:
>> Then try xls file, not ok, when right-click no option prompted ? Do you 
>> know why ?
>>
>
> hi moonhkt,
>
> I don't actually _know_ why, but I suspect that ms is not
> handling the excel (xls) extension the same as the text (txt)
> extension.  I suspect that ms has devised something far more
> complicated.
>
> On my system, there is no such thing as an "xlsfile" registry
> entry.  Granted, my system is probably much older than yours
> -- win98se.  fwiw, you will find listed below the registry
> entries for (my) "standard" xls context menu options, i.e.,
> new, open, print and printto.  If your registry looks anything
> like mine, then that would be the place to start looking to
> make your "backup" context menu addition.
>
> --- <registry stuff> ---
> [HKEY_LOCAL_MACHINE\Software\CLASSES\Excel.Sheet.8]
> "EditFlags"=hex:00,00,01,00
> @="Microsoft Excel Worksheet"

The xlsfile key name is the default name that gets created when you right 
click on an unregistered file extension and check the "always use this 
program" option. If MS Word is installed, xlsfile may be an orphaned hive. 
The following is the correct place (on my system) to check which hive will 
be parsed.

HKEY_CLASSES_ROOT\.xls

The string "(default)" will indicate which hive will be used.

-- 
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages) 

0
Reply Todd 2/25/2010 10:16:13 PM

3 Replies
208 Views

(page loaded in 0.076 seconds)


Reply: