gpt4 book ai didi

c# - CMD C# Window应用程序ProcessStartInfo

转载 作者:太空宇宙 更新时间:2023-11-03 20:03:53 25 4
gpt4 key购买 nike

我需要从 CMD 运行一些东西。在 C# 窗口中。

ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
//info.Arguments = "/K control /name Microsoft.DevicesAndPrinters";
info.Arguments = @"/K cd ../../../../FilesMigration/Solution/FilesMigration/bin/Debug ";
Process.Start(info);

它确实会启动 cmd 并转到指定位置,但现在我需要使用其参数运行“fileMigration.exe”。

我试过这样的:

info.Arguments = "/K filesmigration \"Data Source=(local)/SQLExpress;Initial Catalog=FilesMigration;Integrated Security=true; Connection Timeout=30\""
+ " \"C:/Programing/api/PE_API_Tester/FilesMigration/SCD File System/For Ella/K_Root\""
+ " \"C:/Programing/api/PE_API_Tester/FilesMigration/SCD File System/For Ella/U_Root_Analysis_Clusters\""
+ " \"C:/Programing/api/PE_API_Tester/FilesMigration/SCD File System/For Ella/U_Root_Analysis_Flows\""
+ " \"C:/Programing/api/PE_API_Tester/FilesMigration/SCD File System/For Ella/U_Root_AtpSoftware_MatrixAtp\""
+ " \"notepad\""
+ " \"CO1\""
+ " \"V1\"";
Process.Start(info);

不过好像是在老地方找。我也试过“Console.write”,但它什么也没做。

知道如何正确书写吗?

最佳答案

尝试设置 WorkingDirectory属性而不是自己传递命令

ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.WorkingDirectory = @"../../../../FilesMigration/Solution/FilesMigration/bin/Debug ";
info.Arguments = "/K filesmigration ......";
Process.Start(info);

请检查提供此属性在 UseShellExecute 时的不同行为的链接。是假的

关于c# - CMD C# Window应用程序ProcessStartInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25264045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com