gpt4 book ai didi

c# - System.Diagnostics.Process.Start C# 身份验证问题

转载 作者:行者123 更新时间:2023-11-30 20:48:24 24 4
gpt4 key购买 nike

System.Diagnostics.Process.Start C# 身份验证问题:

我想编写一个可以调用外部函数的编码 UI 测试(我知道如何调用批处理文件,但在这里我想使用 C# 代码调用 exe)

这是我的代码,我可以在某个时候调出登录窗口。但它似乎没有进行身份验证。

public void Login()
{
Char[] input = "********".ToCharArray();
SecureString SecurePassword = new SecureString();

for (int idx = 0; idx < input.Length; idx++)
{
SecurePassword.AppendChar(input[idx]);
}
SecureString secure = SecurePassword;
string FileName = @"C:\\Program Files (x86)\\Helium\\Edition\\7.0\\Gateway\\UserShell.exe";
System.Diagnostics.Process.Start(FileName, "pAlan",secure,"");
}

测试方法 CodedUITest2.CodedUITestMethod1 抛出异常:

System.ComponentModel.Win32Exception: The stub received bad data

最佳答案

尝试声明一个 ProcessStartInfo 变量,不要使用空域参数。如果您不在域下,请使用本地计算机名称。

也尝试使用 de runas 动词来模拟该用户:

ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.UserName = "pAlan";
processStartInfo.Password = secure;
processStartInfo.Verb = "runas";
processStartInfo.Domain = MachineName;
Process.Start(processStartInfo);

关于c# - System.Diagnostics.Process.Start C# 身份验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24627167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com