# How to start cmd, run a long-running GUI program, then close cmd?

I need this when config Listary's custom command to load Rconsole within Explorer, with environment variable R_USER set to current directory for this very command.

What I currently use is effectively same as

cmd /C "set R_USER=%path%&& C:\path\to\Rgui.exe"


(which I learn from here to set environment variable.)

It works fine, except open an extra window for cmd itself. which adds hassle to switch application with Alt-Tab.

How can I achieve same workflow but without open the window for cmd itself?

P.S. (Listary handle the substitution part and run the specified command).

You need to put start command before your executable file path.
start /min "" "path_to_your_program"

The start command tells Windows to execute another CMD window outside the scope of the current CMD. The /min starts the CMD window minimized, and isn't necessary. The first set of double-quotes is definitely necessary, though anything can be placed within those quotes. The second set must contain the absolute path to your program inside.