[英].EXE does not start with Process.Start(path_to.exe)
I have created DatePicker.exe
with Inno Setup. 我已经用Inno Setup创建了
DatePicker.exe
。
Directory: C:\Program Files (x86)\MyJournal
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/17/2017 4:44 AM Log
-a---- 8/17/2017 3:30 PM 2747 appointments.bin
-a---- 8/17/2017 1:46 PM 45056 DatePicker.exe
-a---- 8/8/2017 8:35 AM 189 DatePicker.exe.config
-a---- 8/17/2017 1:46 PM 79360 DatePicker.pdb
-a---- 8/15/2017 10:17 AM 1122 DatePicker.SED
-a---- 8/17/2017 1:47 PM 12946 unins000.dat
-a---- 8/17/2017 1:47 PM 725157 unins000.exe
This does not work - DatePicker.exe
does not open, and there are no errors: 这不起作用
DatePicker.exe
无法打开,并且没有错误:
Process.Start(@"C:\Program Files (x86)\MyJournal\DatePicker.exe");
But this works 但这有效
Process.Start(@"C:\Users\Public\Desktop\MyJournal.lnk");
Link from desktop points to the same path as above. 从桌面指向的链接与上述相同。
Why does the first example not work? 为什么第一个示例不起作用?
UPDATE. UPDATE。
As suggested I have tried to set the working directory. 根据建议,我尝试设置工作目录。 But no luck so far.
但到目前为止没有运气。 This did not work for me.
这对我没有用。
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = @"C:\Program Files(x86)\MyJournal";
startInfo.FileName = @"DatePicker.exe";
startInfo.CreateNoWindow = true;
Process myProcess = Process.Start(startInfo);
UPDATE # 2 ; 更新#2 ;
It finally works with
var psi = new ProcessStartInfo(@"C:\Program Files (x86)\MyJournal\DatePicker.exe");
psi.WorkingDirectory = @"C:\Program Files (x86)\MyJournal";
Process.Start(psi);
Have you tried starting it from the Command Promt? 您是否尝试过从命令提示符启动它? If the application is working fine when manually opening it, it may be because of
UseShellExecute
begin true by default. 如果应用程序在手动打开时运行良好,则可能是因为
UseShellExecute
默认情况下开始为true 。
Try startInfo.UseShellExecute = false;
尝试
startInfo.UseShellExecute = false;
According to MSDN startInfo.CreateNoWindow = true;
根据MSDN
startInfo.CreateNoWindow = true;
is ignored when UseShellExecute
is true or if the UserName
and Password
properties are not null . 当
UseShellExecute
为true或UserName
和Password
属性不为null时,将忽略此UseShellExecute
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.