So I got it working with normal string but now I need to do it in securestring with masking password.
My code looks like this:
Console.WriteLine("Input username:");
            string username = Console.ReadLine();
            Console.WriteLine("Input password:");
            SecureString password = new SecureString();
            password = Classes.Functions.GetPassword();
            Classes.Functions.runProcRasdial("VPN_Arta", username, password);
            Console.Clear();
            Console.WriteLine("VPN Connected.");
Method for calling rasdial:
public static Process runProcRasdial(string VPNName, string username, SecureString password)
    {
        ProcessStartInfo psi = new ProcessStartInfo("cmd")
        {
            RedirectStandardInput = true,
            RedirectStandardOutput = false,
            UseShellExecute = false
        };
        var proc = new Process()
        {
            StartInfo = psi,
            EnableRaisingEvents = true,
        };
        proc.Start();
        proc.StandardInput.WriteLine("rasdial {0} {1} {2}", VPNName, username, password);
        proc.StandardInput.WriteLine("exit");
        proc.WaitForExit();
        return proc;
    }
Method for masking password:
//mask password
    public static SecureString GetPassword()
    {
        var pwd = new SecureString();
        while (true)
        {
            ConsoleKeyInfo i = Console.ReadKey(true);
            if (i.Key == ConsoleKey.Enter)
            {
                break;
            }
            else if (i.Key == ConsoleKey.Backspace)
            {
                if (pwd.Length > 0)
                {
                    pwd.RemoveAt(pwd.Length - 1);
                    Console.Write("\b \b");
                }
            }
            else if (i.KeyChar != '\u0000' ) // KeyChar == '\u0000' if the key pressed does not correspond to a printable character, e.g. F1, Pause-Break, etc
            {
                pwd.AppendChar(i.KeyChar);
                Console.Write("*");
            }
            }
        return pwd;
    }
Problem is Im not getting any error everything looks just fine. But I think there gonna be problem with masking password function because it doesn't accept right password and I dont know.
Do you guys any ideas?
Thanks,
John