看板 C_Sharp 關於我們 聯絡資訊
部分原始碼: private void button1_Click_1(object sender, EventArgs e) { Process.Start("C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\ powershell.exe", test.Text); } test為richtextbox 內容為 @" function aa{ "hello world" } aa read-host " hello world兩邊的"如果不改成\" 那powershell就會跑失敗... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.73.237.242
kyoin:要改成這樣 ""hello world"" 12/20 01:26
bero:可是這樣就要動到我原本的script檔呀...希望可以完全不用改 12/20 01:32
bero:畢竟改\"跟改""對於後續要修改script都會造成一定程度的障礙 12/20 01:34
kyoin:請問一下你在Button_click得到的test.text是你自己輸入在 12/20 01:47
kyoin:richtextbox的值嗎? 12/20 01:48
bero:是的...是在visual studio裡面打的,不是編譯好執行時打的 12/20 15:42
evirtues:試試test.Text.Replace("\"", "\\\"") 12/20 22:09