手把手教你TestComplete_调用cmd命令行程序
来源:互联网 发布:淘宝网购电脑是坏的 编辑:程序博客网 时间:2024/05/01 00:38
调用cmd的命令行程序也是小概率事件,遇到了就变得很重要,本来以为和启动扑通的windows应用程序一样有个简单的命令(例如:Call Win32API.WinExec("notepad.exe", SW_SHOWNORMAL) )就能搞定,结果发现比我想象的复杂多了。这段代码不难,说老实话也没必要去琢磨啥意思,直接调用函数就好了。
'执行cmd的命令,函数调用了readTillChar
'调用方法举例:
'strCmd=ProjectSuite.Path & "\testapp.exe PARAM1"
‘strCmd="dir"
'Call ExecCmd(strCmd)
Sub ExecCmd(strCmd)
Dim WshShellObj, WshShellExecObj, out
Set WshShellObj = CreateObject("WScript.Shell")
Set WshShellExecObj = WshShellObj.Exec("cmd.exe")
' Flush the stream
out = readTillChar(WshShellExecObj, ">")
Log.Message(out)
' Send the command and the new line character
WshShellExecObj.StdIn.Write(strCmd & VbCrLf)
out = readTillChar(WshShellExecObj, ">")
Log.Message(out)
End Sub
Function readTillChar(WshShellExecObj, endChar)
Dim out, curChar
Do While Not WshShellExecObj.StdOut.AtEndOfStream
curChar = WshShellExecObj.StdOut.Read(1)
out = out + curChar
If (curChar = endChar) Then
readTillChar = out
Exit Function
End If
Loop
End Function
附件:
http://download.csdn.net/source/3515481
内含:手把手教你TestComplete_调用cmd命令行程序.txt
- 手把手教你TestComplete_调用cmd命令行程序
- 手把手教你TestComplete_杂七杂八
- 手把手教你TestComplete_调用标准dll实例
- 手把手教你TestComplete_验证码识别
- 手把手教你TestComplete_对象浏览功能
- 手把手教你TestComplete_文件读写示例
- 手把手教你TestComplete_读键盘输入示例
- 手把手教你TestComplete_配置嵌入脚本
- 手把手教你TestComplete_自动发邮件
- 手把手教你TestComplete_修改代理服务器
- 手把手教你TestComplete_暂时告一段落
- 手把手教你TestComplete_怎么捕捉一个动态对象
- 手把手教你TestComplete_对象的等待问题
- 手把手教你TestComplete_数据库操作函数示例
- 手把手教你TestComplete_回放找不着对象了
- 手把手教你TestComplete_自动化测试流程示例
- 手把手教你TestComplete_图文转换OCR示例一
- 手把手教你TestComplete_图文转换OCR示例二
- Java开源建站工具
- Healthy Holsteins
- 在烟台的海边 2011-8-12
- 分享电子工程师的10个好助手网站
- 牙疼时读隋唐英雄们
- 手把手教你TestComplete_调用cmd命令行程序
- 在烟台的日子2011-08-09
- 备份:Android常用到URI及其示例
- 遥感应用实验室海面溢油检测软件(RSALab-OilSensing)V1.0发布!
- 排序算法的稳定性
- winxp下j2me环境,android,nokiaSdk的配置
- iphone 实现裁剪图片
- Android导入工程遇到的问题:没有R.java和android.jar的jar包
- Android笔记:解决eclipse中重载函数时参数为arg0,arg1