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

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

用C#運(yùn)行cmd.exe,需要輸入“Y”

用C#運(yùn)行cmd.exe,需要輸入“Y”

C#
撒科打諢 2023-07-22 18:42:41
我想用System.Diagnostics.Process運(yùn)行cmd命令:“net use * /delete”,但該命令需要輸入“Y”或“N”。這是我的代碼:Process proc = new Process();proc.StartInfo.FileName = "cmd.exe";proc.StartInfo.UseShellExecute = false;proc.StartInfo.RedirectStandardInput = true;proc.StartInfo.RedirectStandardOutput = true;proc.StartInfo.RedirectStandardError = true;proc.StartInfo.CreateNoWindow = true;string dosLine = "/C echo y | net use * /delete";proc.StartInfo.Arguments = dosLine;proc.Start();這些代碼不起作用。我也嘗試過這個(gè):proc.StandardInput.WriteLine("net use * /delete");proc.StandardInput.WriteLine("Y"); 還是不行我應(yīng)該怎么辦?
查看完整描述

1 回答

?
喵喔喔

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

net use需要一個(gè)/y標(biāo)志,所以你可以直接傳遞它。你不需要輸入它。您還可以像這樣簡(jiǎn)化代碼:


Process proc = new Process();

proc.StartInfo.FileName = "net";

proc.StartInfo.Arguments = "use * /delete /y";

proc.StartInfo.UseShellExecute = true;

proc.StartInfo.RedirectStandardOutput = true;

proc.StartInfo.RedirectStandardError = true;

proc.StartInfo.CreateNoWindow = true;

proc.Start();


查看完整回答
反對(duì) 回復(fù) 2023-07-22
  • 1 回答
  • 0 關(guān)注
  • 221 瀏覽

添加回答

舉報(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)