请注意,每个用户帐户都有自己的PATH.因此系统帐户的PATH通常与标准用户帐户的PATH不同.这对于使用命令运行批处理文件非常重要 runas或通过使用不同帐户的任务计划程序.Jason Faulkner 发布的批处理文件在这里也很有帮助.start 在注册表项下进一步查找HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionApp 路径HKEY_CURRENT_USERSoftwareWow6432NodeMicrosoftWindowsCurrentVersionApp PathsHKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionApp PathsHKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftWindowsCurrentVersionApp Paths使用 msiexec 在 App Paths 下注册了他们的文件名,默认字符串值包含完整的可执行文件的名称小路.通常有一个名为 Path 的第二个字符串值只包含应用程序可执行文件的完整路径.其他安装程序也在 App Paths 中注册应用程序,请参阅 Microsoft 文档页面 申请注册.应用路径键>registry hive HKEY_CURRENT_USER 通常不存在,因为安装是使用受信任的安装程序或本地管理员帐户完成的,因此已安装应用程序的注册在注册表 hive HKEY_LOCAL_MACHINE.但是在每个用户安装应用程序时,HKCU 路径用于应用程序注册,而不是 HKLM 路径.Wow6432Node 键下的 App Paths 键仅存在于 Windows x64 上.但是 x86 应用程序通常在两个应用程序路径 中注册,尽管 Wow6432Node 用于 32 位应用程序,另一棵树用于 Windows 7 x64、Windows Server 2008 上的 64 位应用程序R2 x64 和更高版本的 Windows x64.有关详细信息,请参阅 Microsoft 文章 受 WOW64 影响的注册表项.还有一点:即使指定了 .exe,start 也会在当前工作目录以及 PATH 目录中搜索 AppName.exe 额外用于 AppName.exe.* 并根据 PATHEXT 中的文件扩展名检查文件扩展名(上一期之后的字符串),如果返回一个或多个文件名称.尽管如此,指定要启动的应用程序的文件扩展名总是更好,因为如果 AppName.exe 总是在执行通配符搜索之前首先完成对 AppName.exe 的搜索在当前目录中找不到.Sysinternals (Microsoft) 的免费工具 Process Monitor 是一个很好的工具来找出类似的东西.最后但并非最不重要的是,对于无可执行文件start 还会检查 HKEY_CLASSES_ROOT 的文件关联以打开文件或具有为命令 open 定义的关联应用程序的 URI (URL).这就是为什么像下面这样的东西也有效的原因.启动 MyTextFile.txt启动 https://stackoverflow.com/%SystemRoot%System32cmd.exe 包含 start 的代码,使用 Windows shell 函数 ShellExecuteEx 用于执行应用程序或打开文件或关联应用程序的 URL.In my company we use a batch-file to start Matlab. The batch-file prepares the environment before starting Matlab.Matlab itself is started withSTART MATLAB.EXEI have several versions of Matlab installed on my system. And this command is starting the wrong Matlab version. Where is START looking for the executables? 解决方案 Command start finds executables to run like command line interpreter cmd.exe does if no absolute path is used, using additionally the extensions listed in environment variable PATHEXT separated by semicolons if file extension is also missing.Current working directory.All directories of environment variable PATH in order as listed in PATH.Just type in a command prompt window set path to see all directories in PATH as well as all file extensions in PATHEXT.Please note that each user account has its own PATH. Therefore PATH of system account is usually different to PATH of a standard user account. That is very important on running a batch file with command runas or via task scheduler using a different account.The batch file posted by Jason Faulkner is very helpful here, too.start looks further in registry under the keysHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionApp PathsHKEY_CURRENT_USERSoftwareWow6432NodeMicrosoftWindowsCurrentVersionApp PathsHKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionApp PathsHKEY_LOCAL_MACHINESoftwareWow6432NodeMicrosoftWindowsCurrentVersionApp PathsApplications installed with an MSI package (embedded in installer EXE or published separately) using msiexec have their file name registered under App Paths with default string value containing name of executable with full path. There is often a second string value with name Path containing just the full path to the executable of the application. Other installers register an application also in App Paths, see Microsoft documentation page Application Registration.The App Paths key in registry hive HKEY_CURRENT_USER usually does not exist as installation is done using trusted installer or local administrator account and therefore the registration of the installed application is done in registry hive HKEY_LOCAL_MACHINE. But on a per user installation of an application the HKCU path is used for application registration instead of HKLM path.The App Paths key under Wow6432Node key exists only on Windows x64. But x86 applications are registered nevertheless usually in both App Paths although Wow6432Node is for 32-bit applications and the other tree for 64-bit applications on Windows 7 x64, Windows Server 2008 R2 x64 and later Windows x64. For details see Microsoft article Registry Keys Affected by WOW64.One more note:Even with .exe specified, start searches in current working directory as well as in directories of PATH after not found AppName.exe additionally for AppName.exe.* and checks file extension (string after last period) against the file extensions in PATHEXT if this returns one or more file names. It is nevertheless always better to specify the file extension of the application to start as a search for AppName.exe is always done first before the wildcard search is executed if AppName.exe could not be found in the current directory.The free tool Process Monitor of Sysinternals (Microsoft) is a great tool to find out things like that.Last but not least for none executables start checks also HKEY_CLASSES_ROOT for a file association to open a file or a URI (URL) with associated application defined for command open. That is the reason why something like below also works.start MyTextFile.txtstart https://stackoverflow.com/%SystemRoot%System32cmd.exe containing the code for start uses the Windows shell function ShellExecuteEx for executing applications or opening files or URLs with associated application. 这篇关于“开始"在哪里?搜索可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 00:16
查看更多