WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

FileMenu

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Use FileMenu to Get Current File Path
and Copy a File to a Temporary Directory

Keywords:      IntControl(1006   CurrFilePath()   SendTo folder

Question:

This is what I want to do:

Right click on a file and run a WinBatch script which take the path of the file and copies it to a temp directory with the name of the file. (Send file1 to C:\file1\)

I could do this with the SendTo Any Folder PowerToy, but I would like to automate it.

So I guess my question boils down to: Can I send the filename as a variable to Winbatch by right-clicking?

Answer:

  1. You could use FileMenu to grab file file name and use it (or pass it along to a WinBatch script). The CurrFilePath() function would be involved here.
    CurrFilePath is a FileMenu-specific function only, not WinBatch.

  2. You could put a WinBatch script in the SendTo folder and the filename would be passed to it on the command line.

  3. IntControl(1006,...) will give you the unparsed command line to work with.

  4. param1 will give you the first parameter - but it might get confused by spaces in the file name.

  5. There is also a method of adding to the context menu of any or all filetypes, by entering:
     
    RegSetValue(@REGCLASSES, "*\shell\title of Winbatch program\command[]","d:\path\compiledwb.exe %1")
    
    where:

    • * - means all filetypes, you could choose specific ones

    • "The title of Winbatch program" is the name that will appear on the right-click context menu

    • [] - means the (Default) item

    This method is not as easy as the Send To option, but another option just the same.


Article ID:   W13023
Filename:   Use FileMenu to Get FilePath and Copy File.txt
File Created: 1999:04:15:16:51:14
Last Updated: 1999:04:15:16:51:14