第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用.NET以相同的過(guò)程執(zhí)行多個(gè)命令行

使用.NET以相同的過(guò)程執(zhí)行多個(gè)命令行

慕后森 2019-09-21 14:52:45
我試圖執(zhí)行多個(gè)命令而不每次都創(chuàng)建新進(jìn)程。基本上,我想啟動(dòng)DOS命令外殼,切換到MySQL命令外殼,然后執(zhí)行命令。這是我調(diào)用該過(guò)程的方式(也在下面)。另外,如何處理命令中的“ \”?ExecuteCommand("mysql --user=root --password=sa casemanager", 100, false);ExecuteCommand(@"\. " + Environment.CurrentDirectory + @"\MySQL\CaseManager.sql", 100, true);private void ExecuteCommand(string Command, int Timeout, Boolean closeProcess){    ProcessStartInfo ProcessInfo;    Process Process;    ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);    ProcessInfo.CreateNoWindow = false;    ProcessInfo.UseShellExecute = false;    Process = Process.Start(ProcessInfo);    Process.WaitForExit(Timeout);    if (closeProcess == true) { Process.Close(); }}
查看完整描述

3 回答

?
萬(wàn)千封印

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個(gè)贊

您可以重定向標(biāo)準(zhǔn)輸入并使用StreamWriter對(duì)其進(jìn)行寫(xiě)入:


        Process p = new Process();

        ProcessStartInfo info = new ProcessStartInfo();

        info.FileName = "cmd.exe";

        info.RedirectStandardInput = true;

        info.UseShellExecute = false;


        p.StartInfo = info;

        p.Start();


        using (StreamWriter sw = p.StandardInput)

        {

            if (sw.BaseStream.CanWrite)

            {

                sw.WriteLine("mysql -u root -p");

                sw.WriteLine("mypassword");

                sw.WriteLine("use mydb;");

            }

        }


查看完整回答
反對(duì) 回復(fù) 2019-09-21
  • 3 回答
  • 0 關(guān)注
  • 661 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)