title: C# - Process.Start - using global variable as password - "cannot convert from 'string' to 'System.Security.SecureString'
body: <p>I designed a login form and wanted the username and password entered to be stored as variables I could call in other forms (overall program is a collection of .exe files and powershell scripts that I want to run as the username and password initially entered in my login form).</p>
  
  <p>At the start of the program I created "global variables" using this code:</p>
  
  <pre><code>class usernameGlobalVariable
      {
          public static string var = "";
      }
      class passwordGlobalVariable
      {
          public static string var = "";
      }
  </code></pre>
  
  <p>In the login form I stored the username and password entered into these global variables this way:</p>
  
  <pre><code>private void usernameTextBox_TextChanged(object sender, EventArgs e)
      {
          usernameGlobalVariable.var = usernameTextBox.Text;
      }
  
  
      private void passwordTextBox_TextChanged(object sender, EventArgs e)
      {
          passwordGlobalVariable.var = passwordTextBox.Text;
      }
  </code></pre>
  
  <p>When I want to start a process I call it using this code (to run it as the username and password stored by the login form):</p>
  
  <pre><code>string fileName = "c:\\hdatools\\Ping2.exe";
  string arguments = "";
  string domain = "vantage";
  private void Button2_Click(object sender, EventArgs e)
      {
  
      Process.Start(
      fileName,
      arguments,
      usernameGlobalVariable.var,
      passwordGlobalVariable.var,
      domain);
  
      }
  </code></pre>
  
  <p>The main error I get is on the line <code>passwordGlobalVariable.var,</code>
  The error says </p>
  
  <blockquote>
    <p>Argument 4: cannot convert from 'string' to
    'System.Security.SecureString'</p>
  </blockquote>
  
  <p>I've tried different ways to try to convert `passwordGlobalVariable.var' to a secure string, or to give another string variable its contents and then render that variable as a secure string.  I've finally run out of ideas.  Thanks in advance for the help.</p>