qt执行cmd命令
源地址:http://blog.csdn.net/hn307165411/article/details/6858614
运行 route、ipconfig 肯定没问题
Copy code
QProcess p(0);
p.start("route");
p.waitForStarted();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardError());
Copy code
QProcess p(0);
p.start("ipconfig");
p.waitForStarted();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());
而 dir 是命令行提供的命令,不是程序!
Copy code
QProcess p(0);
p.start("cmd");
p.waitForStarted();
p.write("dir\n");
p.closeWriteChannel();
p.waitForFinished();
qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());
或
Copy code
QProcess p(0);
p.start("cmd", QStringList()<<"/c"<<"dir");
p.waitForStarted();
p.waitForFinished();qDebug()<<QString::fromLocal8Bit(p.readAllStandardOutput());
qt执行cmd命令的更多相关文章
- Qt: 执行cmd命令;
QProcess p(NULL); p.setWorkingDirectory(szAppPath+"/database"); //指定工作路径,这个地方一定要设置: p.star ...
- [Qt]执行cmd命令
要加 /c 参数 QProcess p; p.start("cmd", QStringList()<<"/c"<<"ping ...
- JAVA之执行cmd命令
感言在前:时隔好久没有更新博客园了,忙东忙西也没忙出个什么之所以然来.回首过去一两个月,只能用“疲倦”两个字来形容,而且是身心疲惫.每天11.12个小时的工作我都没觉得烦,但是总是想克服却又很难克服的 ...
- [转]Delphi执行CMD命令
今天看到有人在问用代码执行CMD命令的问题,就总结一下用法,也算做个备忘. Delphi中,执行命令或者运行一个程序有2个函数,一个是winexec,一个是shellexecute.这两个大家应该都见 ...
- C# 执行CMD 命令
/// <summary> /// 执行CMD 命令 /// </summary> /// <param name="strCommand">命 ...
- C# 执行CMD命令的方法
/// <summary> /// 执行CMD命令 /// </summary> /// <param name="str"></para ...
- 如何使用Java执行cmd命令
用JAVA代码实现执行CMD命令的方法! Runtime rt = Runtime.getRuntime(); Process p = rt.exec(String[] cmdarray); ...
- java执行cmd命令并获取输出结果
1.java执行cmd命令并获取输出结果 import java.io.BufferedReader; import java.io.InputStreamReader; import org.apa ...
- Java 调用并执行cmd命令
cmd java 调用 执行 概要: Java 调用并执行cmd命令 Java | 复制 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 ...
随机推荐
- VisualSVN Server安装后,TortoiseSVN远程无法访问版本库。
修正!重演了一遍,发现总结有误,重新整理下.首先访问版本库的路径不清楚的话可以在VisualSVN Server的版本库上右键“Copy URL to Clipboard”.访问版本库失败的几种情况: ...
- codeforces 559A(Gerald's Hexagon)
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Gera ...
- Flask对请求的处理
由http://www.cnblogs.com/steinliber/p/5133386.html 中可得服务器会把environ和start_response发送给Flask的实例app,返回的是a ...
- HYSBZ 2818 gcd
/** 大意: 给定整数N,1<= x,y <= N 求解有多少gcd(x,y) 为素数 n=10^7 思路: 首先考虑到n 如此之大,用的快速求欧拉函数. 先默认 y〉x 分析: gcd ...
- (IOS)N duplicate symbols for architecture i386
Xcode编译时的error,出现此情况的汇总引用如下: 1.可能存在两个main入口: 2.导入的.h文件可能误写为.m: 3.两文件间可能存在重复定义的全局变量名: 4.使用#include导入文 ...
- Shell中的正则表达式及字符串处理
shell里一个正则表达式就是由普通字符(例如字符 a 到 z)以及特殊字符(称为元字符)组成的文字模式.该模式描述在查找文字主体时待匹配的一个或多个字符串.正则表达式作为一个模板,将某个字符模式与所 ...
- perl encode_utf8 和decode_utf8
encode_utf8 等于 $octets = encode_utf8($string); 这个字符串 在$string 在Perl的内部格式,返回结果是作为一个顺序的字节. 因为所有的可能的字符串 ...
- 《Python学习手册》
读书笔记请见Github博客:http://wuxichen.github.io/Myblog/reading/2014/10/04/LearningPython.html
- (3)选择元素——(2)文档对象模型(The Document Object Model)
One of the most powerful aspects of jQuery is its ability to make selecting elements in the DOM easy ...
- windows下取linux系统里面的文件
方法一:使用原生态的psftp 1.下载psftp.exe http://pan.baidu.com/s/1boVLHKF 2.双击psftp.exe 2.1 输入指令:open IP地址 (例如:o ...