[Tips] Pass the current folder as parameter to an application launched with QAP

In this tutorial, you will see how to launch an Application favorite with its working directory set to the current folder open in Windows Explorer. You will see that this can be done in two ways:

  • you can pass this folder as the Start In folder (take note that not all applications will use this setting);
  • or you can pass the current folder (or any part of it) as a command-line parameter.

In the following examples, the two techniques produce the same result. But, in real life, some application will support more reliably the Start in options or the Parameters option. Also, the parameters syntax will vary from one application to the other. See what approach works best with your applications.

See this page for more info about the Start In and Parameters settings: What are favorites advanced settings?

To put these two techniques in practice, first create a batch file containing the following two lines:

dir %1

In my example, I saved this batch in C:\TEMP\MyBatch.bat. We will create two favorites of type Application.

Using Start in

For the first technique, add an Application favorite and name it MyBatch Start In. Enter the location of your batch in the first tab. In the Advanced Settings tab, check the Start application in the folder location where this favorite is launched checkbox. The {CUR_LOC} value is entered automatically in the Start in field. Save the favorite.

Now open Windows Explorer in one of your working folders and, in the QAP popup menu (middle mouse button or Windows + W), launch the MyBatch Start In favorite. You will see that the DIR command is executed inside the current folder because the command is "started in" this folder.


Using Parameters

For the second technique, we will use the %1 parameter added to the DIR %1 command in your batch file. In the QAP Settings window, create a new favorite and name it MyBatch Parameter. In the Advanced Settings, insert the code "{CUR_LOC}" in the Parameters zone (make sure you enclose your parameter between double-quotes in case the current folder includes spaces).

In the Current parameters with expanded placeholders text box, you see an example of the command-line parameter that will be passed to your application. The location "x:\containing_folder\last_folder" will be replaced with the location where you will launch your application, the folder "C:\Users\Standard\Documents\Music Docs" in the following example. Save your favorite and launch it in your working folder.


As mentioned earlier, at first sight, the result is pretty the same with the two techniques.  In real-life situations, you will see what approach works best depending on your needs and on your applications capabilities.

Please use the new QAP Support Google Group to ask questions or post comments.