Windows Client > Windows 7 IT Pro Forums > Windows 7 Installation, Setup, and Deployment > Run batch file on selected directory through right mouse button

Answered Run batch file on selected directory through right mouse button

  • Wednesday, January 20, 2010 11:52 AM
     
     
    I have a batch file that cleans up any picked directory [removes files with specified extensions]

    In XP I had it such that I picked a directory, RMB and chose the action.
    The instructions to install this facility were: open any directory tools/ folder options.. /file types/file folder/advanced/new...
    In Action type<name facility>, In Application used to perform action browse to location of batch file.

    Now in Windows7 these instructions don't seem to apply as stuff is in different places.  I can make the facility work by placing the batch file in a directory and running it, but this leaves the batch file to be removed and nothing as easy as it was.

    Can anyone point to how to do this?
    thanks

Answers

  • Monday, January 25, 2010 2:22 AM
     
     Answered

    Hello,

    Please see the following figure and double check the registry key to make sure that it is correct:



    Then you will see the option in background Right-click menu:



    Thomas77

All Replies

  • Thursday, January 21, 2010 8:43 AM
     
     

    Hello,

    I created a similar bat file and added it to Folder Right-Click Menu. When I right click a folder and then click this option to run the bat, it cannot work.  You need to add the option to Directory Right-Click Menu

    Add “run bat file” option to Directory Right-Click Menu

    ==================================
    1. Open regedit, locate to HKEY_CLASSES_ROOT\Directory\Background\shell
    2. Under shell key, create a sub key named "clean".
    3. Under clean key, create a sub key named "command".
    4. Highlight command key, on right panel, set the Default value to D:\test.bat.

    Note: I assume that your bat file is in D:.

     

    5. Open the folder and right click a empty area, you will see the “clean” option. It works for me.


    Thomas77
  • Thursday, January 21, 2010 10:43 AM
     
     
    Thanks for this but it doesn't work for me.
    Following the precise instructions above I got no command in the right click menu.
    I looked back at my old machine[XP] and saw that the old key was under HKEY_CLASSES_ROOT\Directory\shell and placing it here on new machine now did show it in the menu but still failed to work. 

    Placing the file in the directory to be operated on and clicking on it worked suggesting that it's something to do with the filepath or permissions.

    this is the file clean.bat

    CD "%1 %2 %3 %4 %5 %6 %7 %8 %9"

    echo y | del *.chk.*
    echo y | del *.crc.*
    echo y | del *.inf.*


    echo y | del current_session.pro

    @echo off


    Any more ideas? thanks
  • Saturday, January 23, 2010 3:20 PM
     
     
    Hi,

    This is a batch file that I inherited on an earlier machine, I'm not a power user, can anyone give me an idea of why this is not working?

    thanks
  • Monday, January 25, 2010 2:22 AM
     
     Answered

    Hello,

    Please see the following figure and double check the registry key to make sure that it is correct:



    Then you will see the option in background Right-click menu:



    Thomas77
  • Monday, January 25, 2010 8:46 AM
     
     
    thank you
  • Tuesday, January 26, 2010 2:02 AM
     
     

    Hello,

    I would like to know if you can successful run the clean.bat after following the steps above.


    Thomas77
  • Sunday, February 21, 2010 11:33 PM
     
     
    Thanks for this. I used it to add makem3u to the right context menu for making m3u files in music folders.  It works perfectly--if I follow the path directly to the music folder.  If I go the library route, the batch file doesn't show up in the context menu.  I wish there was a way to change the right side start menu links to go directly to folders I designate instead of through libraries.
  • Wednesday, June 22, 2011 2:40 PM
     
     

    Great info, thanks. I have the right click  work but my batch file didn't do as I want it. It works but it will list all items in drive. Exam: if I right click a folder in c:\, my file will contain all the items in c:\ but not the folder I clicked. Somehow, the %1 couldn't capture the path\folder. Could you help me out?

    Purpose: right click a folder and export all items inside that folder to file.

    Code:

    dir %1 /w >c:\filelist.txt

     

  • Sunday, May 20, 2012 4:50 PM
     
     
    I can't see the images above! Can anybody help?