This is closely related to a solution to another question of mine: How to invoke Windows' gvim in a Windows environment from within Cygwin?

I've now found that giving explorer.exe 'C:\Program Files (x86)\Vim\vim73\gvim.exe' in the Cygwin command-line opens Windows' gVim in a Windows context properly. I've written a gvim function in my .bashrc that executes the above command when called without arguments. However, I'd like to know how I can pass on the arguments to the gVim if the function is called with arguments. Trying explorer.exe 'C:\Program Files (x86)\Vim\vim73\gvim.exe' D:\myfile.txt just opens Windows Explorer to the Libraries page, so this direct syntax doesn't work, but I'm unable to find what the correct way to pass these arguments is.
Googling only gives me the list of switches to explorer.exe but nothing about passing arguments to executables executed with explorer.exe.

Edit: Please note that I'm running this from Cygwin, and I've tried many of the more straightforward solutions before landing on using explorer.exe, as documented in the question linked at the top. cygstart and cmd.exe /c both leave remnants of the Cygwin environment within the opened gVim, which causes some issues as mentioned there.

  • 1
    Did you try using start? I think its entire purpose in life is to do what you're trying to coax Explorer into doing.
    – user
    Aug 11, 2013 at 17:53
  • @MichaelKjörling I'm sorry, I don't understand, which start are you referring to? Cygwin doesn't seem to know a command called start, how do I use it?
    – Sundar R
    Aug 11, 2013 at 17:58
  • Michael meant the start command from the Windows command-prompt. Obviously that’s not going to work from the cygwin command-prompt, but you should be able to make it work as I will demonstrate in a moment below…
    – Synetech
    Aug 11, 2013 at 17:59
  • @Synetech Yes, that's the one.
    – user
    Aug 11, 2013 at 18:00
  • Try using just 'C:\Program Files (x86)\Vim\vim73\gvim.exe' D:\myfile.txt (i.e. leave off the explorer.exe. Alternatively, try cmd.exe 'C:\Program Files (x86)\Vim\vim73\gvim.exe' D:\myfile.txt.
    – martineau
    Aug 11, 2013 at 18:17

1 Answer 1


The best way I found to achieve this was to create a batch file containing the call for the executable with the parameters and then running the batch file using explorer.exe. In this case, the batch file runs in the context of the explorer process and everything it runs stays in the same context. It means to create a batch file, let's call it c:\activate.bat and to put inside that file the call C:\Program Files (x86)\Vim\vim73\gvim.exe' D:\myfile.txt. Once the file exists it can be called using explorer.exe %windir%\explorer.exe c:\activate.bat. In my case, I also deleted the file afterward but that's not necessary.

  • You might consider clarifying with an example too. Sep 11, 2017 at 16:38
  • @yuval-perelman: What file did you delete?
    – Moberg
    May 4, 2021 at 7:56
  • @Moberg c:\activate.bat May 4, 2021 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .