通过命令行启动程序有什么区别?通过调用c#API? [英] What's difference between launching a program via command line & via calling c# API?
问题描述
在我看来,从命令行启动程序之间应该有相同的结果:
< program path => < a-parameter>
并通过调用另一个c#程序启动
处理p = new Process();
p.StartInfo.FileName = @ D:\programs\cctv-workstation-sim \ Release\CCTV Workstation.exe;
p.StartInfo.Arguments = wksSID;
p.Start();
但事实是两种方式发射导致不同的结果。在程序执行开始时,两次启动是相同的。但是,在后一阶段,他们采取不同的行动。
推出的&启动程序在c#中。
我应该追踪到它有什么问题。但是如果有人告诉我可能的原因,那就更有效了。
两个程序的行为差异可能是因为您传递给程序的参数。
在两种情况下检查你的参数。
可能的原因是被调用者的环境在两种启动方式上是不同的。如果从另一个c#程序启动它,被叫方可能认为它驻留在与调用者相同的文件夹上。
我将调用者移动到被调用者的文件夹中,然后被调用者启动并运行为预期
In my opinion, it should have the same result between launching a program from command line as:
<program path=""> <a-parameter>
and launching from another c# program by calling
Process p = new Process();
p.StartInfo.FileName = @"D:\programs\cctv-workstation-sim\Release\CCTV Workstation.exe";
p.StartInfo.Arguments = wksSID;
p.Start();
But the fact is that the two ways of launching causes different result. In the beginning of program execution, the two launching is the same. But, in the latter stage, they act differently.
The launched & launching programs are in c#.
I should trace to understand what's wrong with it. But if anyone tells me the possible cause, it's more efficient.
The difference the two programs behave differently is probably because of the parameter you are passing to the program.
Check your parameters in both cases.
The possible reason is that the callee's environment is different in the two ways of launching. In case of launching it from another c# program, the callee may think it resides on the folder same as the caller.
I moved the caller into the folder of the callee and then the callee launched and runs as expected.
这篇关于通过命令行启动程序有什么区别?通过调用c#API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!