从GUI运行Dos命令行 [英] Run Dos command Lines from a GUI

查看:158
本文介绍了从GUI运行Dos命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想知道如何创建一个程序,允许我创建可点击按钮,在GUI界面中运行某些dos命令对Windows 7用户友好。



例如



(对映射驱动器的访问丢失?) < - Button。



以上按钮的dos命令行= C:\ gpupdate / Force



打开一个Windows运行然后关闭。

I would like to know how to create a program that will allow me to create clickable buttons to run certain dos commands in a GUI interface that will be friendly to windows 7 users.

Such as

(Lost access to mapped drives?)<-- Button.

Command line in dos for the above button = C:\gpupdate /Force

open a windows run then close.

推荐答案

在Windows NT / XP / Vista / 7/8中,这个现在称为命令窗口,激活通过使用各种参数调用cmd.exe(/ K和/ C对您来说很重要)。您也可以在程序中使用多个API激活它(这是我假设您想要的,因为您使用C ++标记了您的问题):



- WinExec() //(不要再使用它了)

- CreateProcess()

- system()

- ShellExecute()/ ShellExecuteEx ()

- [其他]



我建议您向Google询问CreateProcess()。
In windows NT/XP/Vista/7/8 this is now called the "command window", activated by calling "cmd.exe" with various parameters (/K and /C are likely important to you). You can also activate this with several APIs within a program (which is what I assume you want since you flagged your question with "C++"):

- WinExec() // (don''t use this any more)
- CreateProcess()
- system()
- ShellExecute()/ShellExecuteEx()
- [others]

I''d suggest you ask Google about CreateProcess().


十多年来没有DOS这样的东西。谈论Windows 7的DOS命令是荒谬的:在过去几个Windows版本中没有这样的东西。这个问题毫无意义。



-SA
There is no such thing as DOS, more than a decade. Talking about "DOS commands" for Windows 7 is just ridiculous: there was no such thing in… several past Windows versions. The question makes no sense at all.

—SA


您正在寻找 http://msdn.microsoft.com/en-us/library/system.diagnostics.process。 aspx [ ^ ]



ProcessCommunicator [< a href =http://www.codeproject.com/Articles/70864/ProcessCommunicatortarget =_ blanktitle =New Window> ^ ]也可能有用。
You are looking for http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^]

and this ProcessCommunicator[^] might be of use as well.


这篇关于从GUI运行Dos命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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