简体   繁体   English

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

[英]System.Diagnostics.Process.Start C# authentication issue

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

I am tying to write a coded UI test which can call external function (I know how to call a batch file but here I would like to call the exe using C# code) 我想写一个可以调用外部函数的编码UI测试(我知道如何调用批处理文件,但是在这里我想使用C#代码调用exe)

Here is my code, I can bring up the log in window sometime. 这是我的代码,我可以在某些时候打开登录窗口。 But it does not seem to authenticate. 但是它似乎无法认证。

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,"");
}

Test method CodedUITest2.CodedUITestMethod1 threw exception: 测试方法CodedUITest2.CodedUITestMethod1引发异常:

 System.ComponentModel.Win32Exception: The stub received bad data 

Try declaring a ProcessStartInfo variable, and don't use empty Domain Parameter. 尝试声明一个ProcessStartInfo变量,并且不要使用空的Domain Parameter。 If you are not under domain, use the local machine name. 如果您不在域中,请使用本地计算机名称。

Try using also de runas verb to impersonate with that user: 尝试也使用de runas动词来模拟该用户:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM