添加应用程序特定的路径,因此它可以从Windows中的命令行工作 [英] Adding a Application specific paths, so it works from the command line in Windows

查看:108
本文介绍了添加应用程序特定的路径,因此它可以从Windows中的命令行工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Microsoft的指南,
http://msdn.microsoft.com/en-us/library/ee872121(VS.85).aspx ,我可以让我的程序能够使程序解决所需的动态库为了它的工作。



所以我添加一个值与我的可执行文件的全名和路径,并添加子项到这个条目(命名为路径)与完整路径DLL文件的目录。



魔法。有用。我去开始菜单,并打开myprogram.exe,它启动,现在可以正确找到dll文件。



但是,如果我启动命令提示符使用命令cmd.exe,然后尝试运行myprogram.exe是不能够解析的DLL了。由于某些原因,当命令提示符设置为HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App路径


$ b时,似乎不尊重/读取注册表的值$ b

任何建议,我可以从命令提示符以及从开始菜单中获得此行为?

解决方案

这是正确的。 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App路径 ShellExecuteEx 使用,而不是由 CreateProcess的。所以并不是所有程序都将使用应用程序的应用程序路径中的设置。如果要为cmd.exe定义 PATH ,您可以使用名称为cmd.exe的应用程序路径的子项或使用旧的%SystemRoot%\System32\autoexec.nt 文件来修改 PATH 环境变量。 p>

Following the guide from Microsoft, http://msdn.microsoft.com/en-us/library/ee872121(VS.85).aspx , I am able to get my program to be able to make a program resolve the dynamic libraries that are required in order for it to work.

So I add a value with the full name and path to my executable, and add subkey to this entry (named path) with the full path the directory of the DLL files.

And magic. It works. I go the start menu, and types myprogram.exe and it starts up and is now able to locate the dll files correctly.

However, if I start the command prompt using the command cmd.exe, and then try to run myprogram.exe is not able to resolve the DLL's anymore. For some reason the command prompt do not seems to respect/read the values of the registry when it is set under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

Any suggestion to how I can get this behavior to work from within the command prompt as well as from the start menu?

解决方案

It is correct. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths is used by ShellExecuteEx and not by CreateProcess. So not all programs will use the settings from App Paths of your application. If you want to define PATH for cmd.exe you can either use subkey of App Paths with the name cmd.exe or use an old %SystemRoot%\System32\autoexec.nt file to modify PATH environment variable.

这篇关于添加应用程序特定的路径,因此它可以从Windows中的命令行工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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