Jump to content

Calling a batch file from context menu


Recommended Posts

Guest ShadowTek
Posted

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.

  • Replies 2
  • Created
  • Last Reply
Guest Newbie Coder
Posted

Re: Calling a batch file from context menu

 

ShadowTek,

 

Take a look at:

 

http://windowsxp.mvps.org/context_folders.htm

 

If you open Google & type "Context Menu Handlers" (with quotes) you will

find your answer

 

--

Newbie Coder

(It's just a name)

 

"ShadowTek" <psistormyamato@cs.com> wrote in message

news:1ff26321-d23c-48c1-b3e9-801bb49d1324@r66g2000hsg.googlegroups.com...

>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.

  • 2 weeks later...
Guest ShadowTek
Posted

Re: Calling a batch file from context menu

 

> Take a look at:

>

> http://windowsxp.mvps.org/context_folders.htm

 

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 ===========


×
×
  • Create New...