How can I run an application with arguments from Windows Explorer?

71,701

Solution 1

If you open any folder, then the shortest way to run any application with arguments is just typing program name and arguments in the upper textbox.

enter image description here
Otherwise, if your program is on Desktop, you can use various ways such as:

  • Click on any folder on your desktop, up one level, and do the same as is in picture.
  • Press Win+R, write cmd.exe /k cd desktop, hit enter, write program name and arguments.
  • Create a shortcut or a batch file with this command:
    cmd.exe /k cd %systemdrive%\%username%\desktop
    run it and write program name and arguments.

Solution 2

It sounds like you want a brief script that you can just double-click to run a command with certain arguments - is that right? If it is, here's one way:

Open a simple text editor, like Notepad, and type in the commands with the arguments you want it to take, like so:

cd %USERPROFILE%\useful-files\executables
putty.exe 192.168.2.10

(In this example, putty.exe is a program that can take IP addresses as arguments, and it's saved in C:\Users\\useful-files\executables.) When you're done, save it with the .bat extension (if you're using Notepad, just make sure you replace the .txt it starts you off with; in our example, we could save it as something like run-putty-with-IP.bat).

If you've done this correctly, in File Explorer it will show the file type as "Windows Batch File" and double-clicking it will run its contents.

Note that certain programs, without configuring system or environment variables, will require you to change to their directory to be able to execute them, hence the cd command included here.

Solution 3

Foggy memory here, but I believe there was a TweakUI addition to the Windows XP context menu for CMD and BAT files that allowed you to add your arguments and run the script. I believe this is what OP is looking for, and I would also find that very useful.

--tim

Share:
71,701

Related videos on Youtube

ajb32x
Author by

ajb32x

Updated on September 18, 2022

Comments

  • ajb32x
    ajb32x almost 2 years

    Is there an easy way to launch an application from Windows Explorer with arguments? Or do I have to actually run them from the command line?

    • CharlieRB
      CharlieRB about 10 years
      Are you limited to command line or launching from Explorer? Would a simple batch file or shortcut work?
  • ajb32x
    ajb32x about 10 years
    Thanks. This is a good answer, but I was really looking for some way of doing this in Windows Explorer without having to create another file.
  • Liviu
    Liviu about 7 years
    how to quit the command window (started by the bat) afterwards ?
  • Liviu
    Liviu about 7 years
    Use start as here: superuser.com/a/192572/185071
  • Mike Clark
    Mike Clark over 3 years
    Hold shift then right-click on the .bat file. Choose "Copy as path." Press WinKey+R to open the run dialog. Paste into run box with Ctrl+V. Add a space and type your arguments. Press enter to run. It's not as complicated as it sounds, and getting used to using "Copy as path" is a good thing, as it can be useful for a wide variety of tasks.
  • Mike Clark
    Mike Clark over 3 years
    Another trick you can use is to open a cmd.exe window and drag the batch file onto the cmd.exe window, where it will paste the full path to the batch file into the command line. You can then type in whatever arguments. This also works for creating arguments. E.g. type dir (with a space after it) in cmd.exe, then drag a folder onto the cmd window and press enter. Or drag a .bat file to the window, press space, then drag a target file to the window. e.g. jpgrotate.bat my.jpg can be achieved by drag'n'drop into cmd.