Calling a batch file from context menu

S

ShadowTek

I would like to create an entry in the context menu that will pass a
file of any type or a group of files of any type along to a batch
file. I don't really know that much about editing the registry, but I
am guessing that I have to create something in "HKEY_CLASSES_ROOT\*
\shellex\ContextMenuHandlers", and make it reference the batch file in
some way.
 
S

ShadowTek

Take a look at:

That helped to explain what is responsible for what. Thanks.

I did manage to develop a simple, working system that will pass along
the names of all selected files to a batch file. The only thing that
that I didn't bother to build in to it was either a safety check that
limits the batch file to only 1 active instance, or a method of using
more a different temp file for each simultaneous batch file instance.
But I am the only person that will be using this, so I won't bother
with it for now.


======= Start Contents of Registry Entry =======

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Custom Context Menu
Item]
@=""

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Custom Context Menu Item
\Command]
@="C:\\Windows\\system32\\cmd.exe /k call \"C:\\Program Files\\+ Batch
Files +\\01\\New.bat\" \"%1\""

======= End of Registry Entry ============


====== Start Contents of New.bat ===========
set Temptxt="C:\Program Files\+ Batch Files +\01\temp.txt"
if exist %Temptxt% (
echo %1 >> %Temptxt%
exit
) else (
echo %1 > %Temptxt%
ping 127.0.0.1 -n 2
call :CheckTempFileSize
call :processFileList %Temptxt%
del %Temptxt%
set Temptxt=
)
goto :eof

:CheckTempFileSize
call :SetTempFileSizea %Temptxt%
ping 127.0.0.1 -n 2
call :SetTempFileSizeb %Temptxt%
if %TempFileSizea%==%TempFileSizeb% (
set TempFileSizea=
set TempFileSizeb=
goto :eof
) else (
call :CheckTempFileSize
goto :eof
)

:SetTempFileSizea
set TempFileSizea=%~z1
goto :eof

:SetTempFileSizeb
set TempFileSizeb=%~z1
goto :eof

:processFileList
cd "%~dp1"
for /f "tokens=*" %%G in (%~nx1) do (
set WorkingFile=%%G
call :Actions01 %%G
)
goto :eof

:Actions01
// Do stuff with %1

====== End of New.bat ===========
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top