从CMD中检测命令行应用程序,而不会干扰PATH变量或System32 / SysWow64 dir [英] Detect commandline application from CMD without messing with PATH variable or System32/SysWow64 dir
问题描述
场景
我想在 C:\Windows之外的文件夹上安装 x86 CommandLine应用程序\ System32
或 C:\Windows \Syswow64
,仍然可以访问我的应用程序在CMD下,而不添加我的应用程序的路径 PATH
环境变量。
问题
去做?
注意:我知道如何将我的应用程序添加到 PATH
variable / regvalue如何从CMD访问我的应用程序将所需的.exe放在 System32
/ SysWow64
文件夹中。这个问题只是为了学习替代方法,不是解决 PATH
或系统 dirs的问题。
代码
我试过这个建议的方法从@Sertac Akyuz的评论在这个答案,我已经存储了 MyApp.exe
在
C:\
根目录,但我不能检测到应用程序只是把 MyApp.exe
下的CMD。
Windows注册表编辑器版本5.00
[HKEY_CURRENT_USER \ Software \Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
@ =C:\\MyApp.exe
[HKEY_CURRENT_USER\\ \\软件\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
@ =C:\\MyApp.exe
[HKEY_LOCAL_MACHINE \ Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
@ =C:\\MyApp.exe
[HKEY_LOCAL_MACHINE \Software\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
@ =C:\\MyApp.exe
解决方案
应用程序路径
注册表设置 - ,在运行...框中键入程序名称时定位程序,依此类推。这些设置不会影响cmd.exe
行为。
设置
cmd.exe
路径用于搜索应用程序是更改PATH
环境变量。您可以从自己的.bat
/.cmd $ c开始
cmd.exe
$ c>您为当前会话设置所有必需的变量,而不会在全局更改。Scenario
I would like to install an x86 CommandLine application on a folder outside
C:\Windows\System32
orC:\Windows\Syswow64
and still be able to access my app under CMD without adding my application's path inside thePATH
environment variable.Question
Is this possible to do? Maybe touching a needed registry keys?
Note: I know how to add my application into
PATH
variable/regvalue or how to access my application from CMD putting the required .exe in theSystem32
/SysWow64
folder. This question is only to learn alternatives, it's not to solve issues withPATH
or System dirs.Code
I've tried this suggested approach from a comment of @Sertac Akyuz in this answer, I have stored
MyApp.exe
onC:\
root directory, but I can't detect the application just puttingMyApp.exe
under the CMD.Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe] @="C:\\MyApp.exe" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe] @="C:\\MyApp.exe" [HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe] @="C:\\MyApp.exe" [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe] @="C:\\MyApp.exe"
解决方案
App Paths
registry settings - used by Windows Explorer, to locate programs when you type program name in "Run..." box, and so on. These settings are not affectingcmd.exe
behavior.The only way to set up
cmd.exe
paths for searching applications is changingPATH
environment variable. You can startcmd.exe
from your own.bat
/.cmd
where you set up all required variables for current session, without changing it globally.这篇关于从CMD中检测命令行应用程序,而不会干扰PATH变量或System32 / SysWow64 dir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!