Batch file in right click menu

Posted on

QUESTION :

I’m making a batch file that is going to encrypt information. I made it so when I right click on the object and click on the “test” button it runs the batch file.

In regedit I added

ComputerHKEY_CLASSES_ROOT*shellTestcommand

command’s data is

C:Users%username%Desktopencrypt.bat

What do I need to do to the data (in the registry key i added) and what is it stored as in my variable?

ANSWER :

You need to associate to the filetype the script you want to launch on that type. On Windows, all this is based on the extension (at least on XP, I don’t know about 7, but I doubt it has changed).
Say the extension of your files are “.abc”, and your app is:

c:program filesdummyprocess.bat

(I dropped the variable for the moment, I’m not sure how this behaves in .reg files)

So just edit a config.reg text file that will hold the following:

Windows Registry Editor Version 5.00

; the extension .abc gets associated with a file type
[HKEY_CLASSES_ROOT.abc]
@="abc-file"

; the file-type gets a name (that appears in explorer in field "type")
[HKEY_CLASSES_ROOTabc-file]
@="foo file"

; What will appear in the contextual menu when selecting an .abc file
[HKEY_CLASSES_ROOTabc-fileshellcmdname-1]
@="--- Process ! ----"

; What to do with it
; here, %1 is the file given as argument of the script
[HKEY_CLASSES_ROOTabc-fileshellcmdname-1command]
@=""c:\program files\dummy\process.bat"" ""%1""""

Leave a Reply

Your email address will not be published.