从CMD中检测命令行应用程序,而不会干扰PATH变量或System32 / SysWow64 dir [英] Detect commandline application from CMD without messing with PATH variable or System32/SysWow64 dir

查看:694
本文介绍了从CMD中检测命令行应用程序,而不会干扰PATH变量或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 cmd.exe $ c>您为当前会话设置所有必需的变量,而不会在全局更改。


Scenario

I would like to install an x86 CommandLine application on a folder outside C:\Windows\System32 or C:\Windows\Syswow64 and still be able to access my app under CMD without adding my application's path inside the PATH 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 the System32/SysWow64 folder. This question is only to learn alternatives, it's not to solve issues with PATH or System dirs.

Code

I've tried this suggested approach from a comment of @Sertac Akyuz in this answer, I have stored MyApp.exe on C:\ root directory, but I can't detect the application just putting MyApp.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 affecting cmd.exe behavior.

The only way to set up cmd.exe paths for searching applications is changing PATH environment variable. You can start cmd.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屋!

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