Im trying to execute cmd commands through c# and everything works well. How can i execute a "runas" cmd including the password, or at least how can i open the cmd prompt for inserting the password. My code execution works well, this is the only thing that i cant seem to solve. I've tried even with echo but it doesnt seem to work.
private void btnStart_Click(object sender, EventArgs e)
{
    txtResult.Text = string.Empty;
    if (txtExecutable.Text.Trim() != string.Empty)
    {
        StreamReader outputReader = null;
        StreamReader errorReader = null;
        try
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.CreateNoWindow = true;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = @"/C echo " + txtpass.Text + " | runas /user:" + utente.Text + " wmic.exe /node:" + txtExecutable.Text + " ComputerSystem Get UserName && tasklist /s " + txtExecutable.Text + @" /fi ""imagename eq EmpirumRCHost.exe"" && msinfo32.exe \\" + txtParameter.Text;
            startInfo.ErrorDialog = false;
            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardError = true;
            startInfo.RedirectStandardInput = true;
            startInfo.RedirectStandardOutput = true;
            process.StartInfo = startInfo;
            process.Start();
            bool processStarted = process.Start();
            if (processStarted)
            {
                //Get the output stream
                outputReader = process.StandardOutput;
                errorReader = process.StandardError;
                process.WaitForExit();
                //Display the result
                string displayText = "Output" + Environment.NewLine + "==============" + Environment.NewLine;
                displayText += outputReader.ReadToEnd();
                displayText += Environment.NewLine + "Error" + Environment.NewLine + "==============" +
                               Environment.NewLine;
                displayText += errorReader.ReadToEnd();
                txtResult.Text = displayText;
            }
        }
        finally
        {
            if (outputReader != null)
            {
                outputReader.Close();
            }
            if (errorReader != null)
            {
                errorReader.Close();
            }
            btnStart.Enabled = true;
        }
    }
}
I need to run the runas command as a domain user with administrative rights on a remote pc.
 
     
     
    