I’m working on a project right now where I often have to grab a master copy of a single file, paste it into my current working directory and open it for editing. My environment is Windows 7.
Since the master file exists in a static location, I wrote a batch script to copy the file into my current directory and open it.
copy %ANT_HOME%\..\..\build.xml . /-Y build.xml
The first line of this script will copy the master version of build.xml into whatever directory I run it from from. The -Y option prompts me to overwrite if a file named build.xml happens to be present. The second line will open the local file in the system default editor for .xml files (if you have one configured). So it’s just two lines. Nice and simple and it sure beats doing this manually.
To make this script callable from anywhere on my file system, I placed it in a directory that is included in my PATH and I called it getBuild.bat.
At this stage, calling the script requires me to SHIFT+right-click > Open Command Prompt Here and type the name of the batch file. Too many clicks and keystrokes for my liking.
Ideally, I’d like to be able to access this functionality from the context menu and bypass the need to open the command window at all. Here’s how I did it.
- Open regedit.exe
- Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell
- Add a new key called getBuild
- Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\getBuild
- Add a new key called command
- Modify the (Default) value and set it to C:\Windows\System32\cmd.exe /c getBuild.bat
- Save and close the registry editor
- Open Windows Explorer and right click on a file in any directory to see the new context menu item. I haven’t bothered to try to make it work by right clicking anywhere so as it stands, you have to right click a file.
- Next, you’ll see the prompt to overwrite the .existing file.
- Answering ‘y’ opens the file in my editor.
If you’re wondering why I need to copy build.xml so often, keep an eye on this space for my next blog post. I’ll be talking about the ANT build script I wrote to package and deploy WebWorks apps to the upcoming BB10 smartphone. But until then, happy copying.

















