How do I launch a program from command line without opening a new cmd window?

前端 未结 9 859
走了就别回头了
走了就别回头了 2020-12-01 16:00

I\'m trying to programmatically execute an external file from cmd using this command:

START \"filepath\"

Where \"filepat

9条回答
  •  旧巷少年郎
    2020-12-01 16:53

    If you're doing it via CMD as you say, then you can just enter the command like so:

    path\to\your.exe 
    

    which will open it within the same window. For example in C++:

    system("path\\to\\your.exe"); // Double backslash for escaping
    

    will open your.exe in the current CMD window. Likewise to start with a new window, just go for:

    system("start path\\to\\your.exe");
    

    If you go for the first option, you would have to clear your screen unless you wanted to have the command to open your.exe on the screen still.

提交回复
热议问题