Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to perform a particular set of operation in large number of directories. In order to save time and effort, I created a batch file containing all the set of commands I have to run. But now I am facing one more problem I.e. I have to paste the batch file in a directory before running it. If some how I can put this batch file as command on Windows explorer toolbar, I will further save my time.

Is it possible to do so in Windows XP?

share|improve this question

migrated from Nov 23 '11 at 23:10

This question came from our site for system and network administrators.

I'm slightly confused as to the nature of the problem. Could you perhaps give an example of your typical use case? A copy of the batch file (if it's not too long) may be useful also. – Iszi Nov 23 '11 at 23:17
Lets suppose I have a directory containing my project binaries. Now I have to load them on a hardware. In order to load, I have to first set some environment variables and then run a set of commands. – Ravi Gupta Nov 24 '11 at 6:01
Yeah.. I know that copy/paste a batch file is not a big issue but as I have to do it quite frequently for various projects ... I was thinking that if some how that batch file can be added as a button on the windows explorer toolbar along with the back, forward, up, search, folders etc buttons, it would be a great help to me. – Ravi Gupta Nov 24 '11 at 6:05

You could add the batch file to your SendTo menu. On Windows XP, the contents of this menu are stored, by default, in C:\Documents and Settings\*username*\SendTo. This folder is hidden by default.

You could then right-click any directory, go to the Send To menu, and choose your batch file. The first argument to your batch file, that is %1, will be the path of the folder you right-clicked.

Consider this simple batch file:

@echo off
echo first parameter = %1

Save this batch file as batch.cmd and place it in your SendTo folder. Then if you right-click, say, C:\Program Files, choose Send To, and then batch.cmd, the output will be

first parameter = "C:\Program Files"
Press any key to continue . . .

Note: For Windows Vista and 7, the SendTo folder is at C:\Users\*username*\AppData\Roaming\Microsoft\Windows\SendTo.

share|improve this answer

I'm still not quite entirely clear on the nature of the problem here, so pardon if none of this is useful. But, these are some options that come to mind. None of them will add a button to Explorer (I think there's some actual programming required to do that), but they should help make your life easier.

  1. Instead of copying the batch file all over the place whenever you need it, just drop a copy in one of the locations specified by %PATH%. This way, you can run the batch file from the command line, regardless of what your current working directory is.

  2. Instead of copying the batch file to a location already specified in %PATH%, you could edit %PATH% yourself to point to another location where you keep the batch file.

  3. Skipping either of the above options (or as an enhancement to them), you could re-write the batch file so that it can be fed a parameter that points it to where it needs to work. This way, you can run it from whatever location you'd like to keep it in and still have it do its work wherever you want.

For option 1:

  • From any command prompt, run the following command: echo %PATH%
  • Copy your batch file to one of the locations listed.

For option 2:

  • Run the following command: sysdm.cpl
  • On the "Advanced" tab, click the "Environment Variables..." button.
  • In the lower half of the resulting dialog, look for the "Path" variable and select it.
  • Click the "Edit..." button in the lower half of the dialog.
  • Add the path to your batch file at the end, making sure there is a semicolon separating your path from the last entry in the variable, and another semicolon at the end of your path.
  • Click "OK" for each of the open dialogs, to save your settings.

For option 3:

  • Add the following line to the start of your batch file:
    • cd /d %1
  • Whenever you run the batch file from the command line, specify the path that you want it to work in.
    • Make sure to enclose the path in quotes, if it includes spaces.
    • Also include the drive letter.
    • Example1: mybatfile.bat C:\Workingdirectory1
    • Example2: mybatfile.bat "C:\Documents and Settings\Me\Desktop\My Working Directory"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.