为什么Process.Start没有打开我的win32应用程序 [英] Why does Process.Start not open my win32 app

查看:253
本文介绍了为什么Process.Start没有打开我的win32应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行.exe,这是一个用Smalltalk编写的Windows应用程序。



它位于C:\Program Files(x86) \ AppFolder\app.exe



我想打开应用程序(与双击app.exe时的工作方式相同)。



当我执行以下内容时,它实际上并没有启动应用程序。我看到部分启动画面但是应用程序无法打开。我看到一个进程已经启动但是我看不到应用程序屏幕...



Process.Start(@C:\Program Files(x86)\\ \\ AppFolder \\\ app.exe);



注意,我可以使用以下命令运行.bat文件,这可以从c#中运行..



I am trying to run an .exe that is a windows app written in Smalltalk.

It is located at "C:\Program Files (x86)\AppFolder\app.exe"

I want to open the app (in same way as how it works when you double click on app.exe).

When I execute the following it does not actually start the app. I see part of the splash screen but then the app does not open. I see that a process has started but I do not see the app screen...

Process.Start(@"C:\Program Files (x86)\AppFolder\app.exe");

Note, I can run a .bat file with the following and this does work from c#..

cd "C:\Program Files (x86)\AppFolder"
app.exe
exit





为什么这不起作用?如何让c#程序执行.exe,就像它从文件夹中调用一样?



提前致谢

John



Why does this not work and how do I get the c# program to execute the .exe as if it called from the folder?

Thanks in advance
John

推荐答案

这两种方式并不相同。



要模仿批处理行为,首先要更改当前目录: https://msdn.microsoft.com/en-us/library/syste m.io.directory.setcurrentdirectory%28v = vs.110%29.aspx [ ^ ]。



当然,正确书面申请表现得很好。它们要么忽略当前目录(任何人都可以使用绝对任何目录来启动任何应用程序;它也称为启动目录),或者输入/输出文件位置完全取决于此目录(对于仅限控制台的应用程序而言是典型的方法),但它所有情况下,它都会很好地告诉你它的期望。但是愚蠢的人经常写出行为不好的应用程序。但是为什么要使用它们?



无论如何,我完全回答了你的问题;请试一试。



-SA
These two ways are not equivalent.

To mimic your batch behavior, first change the current directory: https://msdn.microsoft.com/en-us/library/system.io.directory.setcurrentdirectory%28v=vs.110%29.aspx[^].

Of course, correctly written applications behave nicely. They either ignore current directory (anyone can use absolutely any directory to start any application; it's also called "start directory"), or input/output file locations would totally depend on this directory (approach typical for console-only applications), but it all cases it would nicely inform you on what it expects. But stupid people often write application which don't behave nicely. But why using them?

Anyway, I fully answered your question; please try it out.

—SA


这篇关于为什么Process.Start没有打开我的win32应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆