问题描述
我正在尝试在远程计算机上运行编码的ui测试.我们正在测试的应用程序需要以管理员身份运行.当应用程序以常规用户身份运行时,测试可以正常进行.当应用程序以管理员身份运行时,测试 启动应用程序,然后一直在那里等待.
I am trying to run a coded ui test on a remote machine. The application we are testing requires to be run as a administrator. When the application is run as a regular user, the test works fine. When the application is run as a administrator, the test starts the application and just keeps waiting there.
MTM正在另一端以管理员身份运行.我还尝试过以管理员身份运行测试代理,但这没有任何区别.
MTM is running as a administrator at the other end. I also tried to run the test agent as administrator but it didn't make any difference.
以管理员身份运行被测试的应用程序时,我需要进行一些特殊设置吗?有人在这种情况下有经验吗?
Is there any special settings I have to make when the app being tested is run as administrator? Anyone has experience on this scenario?
预先感谢.
推荐答案
您可以尝试以下代码:
string password = "[your password]";
var pass = new SecureString();
for (int x = 0; x < password.Length; x++)
{
pass.AppendChar(password[x]);
}
var psi = new ProcessStartInfo
{
FileName = "notepad",
UserName = "[user name]",
Domain = "[domain]",
Password = pass,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true
};
Process.Start(psi);
更多信息,请参考此主题:
More information, please refer to this thread:
#如何在C#中以管理员身份启动进程
http://stackoverflow.com /questions/2532769/如何在C锐化模式下以管理员模式启动进程
致谢
Starain
这篇关于当应用程序以管理员身份在远程计算机上运行时,CodedUI自动化不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!