My goal is to have a right-click context-menu-item called 'BACKUP'...
Every file and folder, when right clicked, will have access to this menu item.
And each item will be sent to the same location. D:\MUSTSAVE\
USING REGEDIT
Navigate to HKEY_CLASSES_ROOT\*\SHELL
Right click 'shell' and choose 'New' then 'Key'.
Rename this key to 'BACKUP'
Inside this key I create another key called 'command'.
With the 'command' key selected, edit the '(Default)' string by double clicking (right pane).
In the blank field I reference the name of my batch file and any parameters
I used,
c:\save.bat %1
To apply this to folders, navigate to HKEY_CLASSES_ROOT\DIRECTORY\SHELL and create the same keys.
Now, I know that the command needs to differ, depending on the backup item. (Item or folder).
So I added a parameter to the 'BACKUP' string in the 'Directory' location. I simply used the word 'folder'.
c:\save.bat %1 folder
My c:\Save.bat contained:
Code: Select all
if %2==folder goto robo
if not exist d:\MUSTSAVE md d:\MUSTSAVE
copy "%1" "d:\MUSTSAVE\%~nx1"
pause
:robo
if not exist d:\MUSTSAVE md d:\MUSTSAVE
robocopy %1 d:\MUSTSAVE\%~nx1
pause
Robocopy handles the folders fine, but if %2 is not equal to 'folder' the bat just exits.
Can someone help me please. Thanks.