ProcessStartInfo在PATH环境变量中运行exe
我正在尝试使用 ProcessStartInfo 运行 exe。问题是我只想指定exe名称,并将可执行路径添加到Windows中的PATH环境变量中。当我尝试运行我的应用程序时,我收到了 FileNotFoundException。当我使用全名启动该过程时,一切正常。有什么想法吗?
-- 编辑:感谢您的评论,我将举一个例子来更清楚地说明:
ProcessStartInfo p = new ProcessStartInfo("example.exe");
我手动在 Windows 环境 PATH 变量中添加了 example.exe 的路径,但我的应用程序仍然无法启动进程 example.exe
I'm trying to run an exe using ProcessStartInfo. The problem is I only want to specify the exe name, and add the executable path to the PATH environment variable in Windows. When I try to run my application I got a FileNotFoundException. Everything works fine when I start the process with the full name. Any ideas?
--
Edit: Thanks for the comments, Ill give an example to make it more clear:
ProcessStartInfo p = new ProcessStartInfo("example.exe");
I added the path of example.exe in the Windows Envirionment PATH variable manually, but still my application can't start the process example.exe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
GetEnvironmentVariable
和SetEnvironmentVariable
位于环境
类。You can use
GetEnvironmentVariable
andSetEnvironmentVariable
that are on theEnvironment
class.您可以在注册表中的HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths项中创建子项。
查看注册使用应用程序路径子键的应用程序。
You could create a sub key in the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths in the registry.
Have a look at Registering Applications Using the App Paths sub key.