如何在不打开窗口的情况下调用CMD [英] How to call CMD without opening a window

查看:269
本文介绍了如何在不打开窗口的情况下调用CMD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++方法(使用Visual Studio,如果有帮助的话),可以像这样调用cmd:

I've an C++ method (using Visual Studio, if it helps) that calls to cmd like this:

start \B example.exe arg1 arg2 arg3

问题是此调用打开了一个(cmd)窗口。如果我打开了另一个cmd,\B会起作用,但如果不打开,它将打开一个新窗口。

The problem is that this call opens a (cmd) window. If i have another cmd opened, \B works, but if not, it opens a new window.

我也尝试了不使用\B的情况,但这是相同的。 ...

I also tried without start \B but it's the same....

我想避开这个新窗口,但我不知道如何。知道吗?

I want to avoid this new window, but I don't know how. Any idea?

推荐答案

我不知道如何在C ++中做到这一点,而是打开一个新的命令提示符窗口,该窗口也已最小化(或隐藏)使用批处理文件,我将使用:

I dont know how to do it in C++ but to open a new command prompt window that is also minimized (or "hidden") using a batch file i would use:

start /min cmd

或者如果您启动命令提示符,则可以键入:

Or if you start the command prompt you can type:

@echo off
cls && start /b cmd

这将重新启动当前命令提示符窗口,但不关闭它,但是所有先前设置的环境变量被重置。希望这可以帮助!

This restarts the current command prompt window with out closing it, however all previously set environment variables are reset. Hope this helps!

(PS。这已经过测试,并在Windows 7 Ultimate OS上成功运行)

(PS. This was tested and was successful on Windows 7 Ultimate OS)

这篇关于如何在不打开窗口的情况下调用CMD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆