如何使用Process.Start()从CodedUI脚本执行.bat或exe文件? [英] How to execute a .bat or exe file from CodedUI script using Process.Start()?

查看:171
本文介绍了如何使用Process.Start()从CodedUI脚本执行.bat或exe文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,


我是Coded UI的新手。我编写了一个简单的代码来执行CodedUITestMethod1()中的.bat文件,如下所示:

 thisProcess.StartInfo.CreateNoWindow = true; 
thisProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
thisProcess.StartInfo.FileName = @" C:\ BVTBatch \PlayBack.bat" ;;
thisProcess.StartInfo.UseShellExecute = false;
thisProcess.StartInfo.RedirectStandardOutput = true;

thisProcess.Start();
thisProcess.WaitForExit();
strException = thisProcess.StandardOutput.ReadToEnd();

问题陈述:当我调试脚本时,它会被执行但批处理文件不会运行。我尝试执行iexplorer.exe,并观察到同样的问题。脚本通过传递执行,但IE浏览器无法启动。


但是,如果我从其他控制台应用程序或单元测试项目方法执行相同的代码,它将成功执行。


有人可以说明这背后的原因是什么?我们如何在CodedUI中解决这个问题?


提前致谢。


 


解决方案

嗨ringhals,


根据您的描述,您的问题与编码UI测试有关,测试工具论坛是这个问题的好地方我会把它移到那里。


问候


Starain


Hello Everyone,

I am new to Coded UI. I have written a simple code to execute a .bat file from a CodedUITestMethod1() as below:

thisProcess.StartInfo.CreateNoWindow = true;
thisProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
thisProcess.StartInfo.FileName = @"C:\BVTBatch\PlayBack.bat";
thisProcess.StartInfo.UseShellExecute = false;
thisProcess.StartInfo.RedirectStandardOutput = true;
                            
thisProcess.Start();
thisProcess.WaitForExit();
strException = thisProcess.StandardOutput.ReadToEnd();

Problem statement: When I debug the script, it gets executed but the batch file does not run. I tried executing iexplorer.exe, and observed same issue. The script gets executed with pass, but IE browser does not start.

However if I execute the same code from other console application or Unit Test project method, it gets executed successfully.

Can someone suggest what is the reason behind this? and how can we fix this in CodedUI?

Thanks in advance.

 

解决方案

Hi ringhals,

According to your description, your issue is related to Coded UI Test, the test tool forum is the better place for this issue and I will move it there for you.

Regards

Starain


这篇关于如何使用Process.Start()从CodedUI脚本执行.bat或exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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