从ECHO运行Windows .exe文件,但阻止出现消息框. [英] Run windows .exe file from ECHO but prevent message box.

查看:119
本文介绍了从ECHO运行Windows .exe文件,但阻止出现消息框.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.exe文件,可以将.dll文件安装到您的计算机上.条件只有在成功的情况下,出现提示说.dll文件已正确安装的消息框,否则显示错误消息框的消息.

但是,当我从ECHO运行此程序时,我不想提示消息框,但我想在回显屏幕中显示一条消息,指出已安装或错误,但是如果再次运行而没有回显,则必须提示消息框,所以有是类似switch之类的东西,可用于检查它是直接运行还是通过回显运行,然后能够防止出现消息框.

干杯,
Mohit

I have an .exe file that install .dll files to your machine. the conditions are only that if it success if prompt a message box saying .dll file has been installed correctly and if not it prompt a error message box.

But while i run this program from ECHO i do not want to prompt message box but i want to show a message in echo screen saying installed or error but again if it''s run without echo it has to prompt message box, so there has to be something like switch which can be used to check if it''s run directly or from echo and then able to prevent message box.

Cheers,
Mohit

推荐答案

编写您的逻辑以检查exe中的父进程.如果父进程名称为cmd.exe,则可以在代码上写一条消息控制台其他显示消息框.
Write your logic to check the parent process in your exe.if the parent process name is cmd.exe then you can put your code to write a message on console else show message box.


命令行参数似乎是最干净的解决方案,您可以使用 ^ ].

例如
myprog.exe这样启动程序将显示一个消息框,但
myprog.exe -console将使用控制台输出.

通过资源管理器打开myprog.exe时,未添加任何命令行参数,因此,如果手动启动它,则会显示一个消息框.
A command line argument seems the cleanest solution, you can use GetCommandLine[^] from your exe file.

e.g.
Starting the program like myprog.exe will show a messagebox, but
myprog.exe -console will use console output.

When opening myprog.exe via the explorer, no command line arguments are added so you''ll get a messagebox if you start it manually.


我假设您的意思是,如果控制台处于活动状态,那么您想要在其中显示消息,但是如果没有控制台(当它们直接从资源管理器运行您的应用程序时发生),那么您想要显示一个消息框.您可以调用GetConsoleWindow ,如果它返回NULL,则可以通过MessageBox显示信息/错误消息,否则可以使用coutprintf.
I assume what you mean is that if the console is active, then you want to show your messages there but if there is no console (as happens when they run your app directly from explorer), then you want to show a messagebox. You could call GetConsoleWindow and if it returns NULL, then you show your info/error messages through MessageBox, else you can use cout or printf.


这篇关于从ECHO运行Windows .exe文件,但阻止出现消息框.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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