我正在尝试从C#在自定义.cmd中运行命令。问题在于命令提示符准备就绪时,命令没有传递给提示符。这是我的代码:
<script>
let items = ['a', 'b', 'c', 'd', 'e'];
$: filteredItems = items.slice(0, 4);
const filterItems = (i) => i.slice(0, 4);
</script>
<div>
{#each {length: 4} as _, i}
{items[i]}
{/each}
</div>
<div>
{#each items.slice(0, 4) as item}
{item}
{/each}
</div>
<div>
{#each filteredItems as item}
{item}
{/each}
</div>
<div>
{#each filterItems(items) as item}
{item}
{/each}
</div>
我看到命令窗口打开,但是命令没有传递给它,也没有输出。
答案 0 :(得分:0)
您的命令作为参数传递,该参数看起来像是空格。要使用空格传递参数,您需要将该参数用引号引起来。
proc1.UseShellExecute = false;
//wrap Command in quotes
string Command = @"""Depanalyzer targets /n Dev\Tools\CleanupPerfCounters.exe""";
proc1.FileName = @"C:\Users\xx\Desktop\MyCustom.cmd";
proc1.RedirectStandardOutput = true;
proc1.Verb = "runas";
//add quotes
proc1.Arguments ="/k " + Command;
p.Start();
string output = p.StandardOutput.ReadToEnd();