gpt4 book ai didi

windows - FINDSTR 在从 Windows XP 到 Windows Server 2012 的所有 Windows 操作系统上的位置是什么?

转载 作者:可可西里 更新时间:2023-11-01 09:52:45 26 4
gpt4 key购买 nike

对于从 Windows XP 到服务器 2012 的所有操作系统,findstr 的目录是否总是 C:\Windows\system32\

或者换句话说,在 Windows 批处理文件中替换以下表达式是否安全:

findstr

C:\Windows\system32\findstr

最佳答案

额外的信息只是为了完整性。

环境变量 windir 自 Windows 95 以来就存在,它包含 Windows 目录的路径,与它所在的驱动器和名称无关。

对于基于 NT 的 Windows(NT4、Windows 2000、Windows XP、Vista、Windows 7/8/8.1),还有环境变量 SystemRoot,它还包含 Windows 目录的路径,因为这是系统目录的父目录

  • System32
  • Sysnative(仅 Windows x64 且仅适用于 32 位应用程序)
  • SysWOW64(仅限 Windows x64)

有关文件系统重定向的详细信息,请阅读 File System Redirector微软的页面。

这两种方法不仅安全

%windir%\System32\findstr.exe

%SystemRoot%\System32\findstr.exe

我强烈建议在批处理文件中始终使用这两个字符串之一,因为它不依赖于环境变量 PATH 中的文件夹以及环境变量 PATHEXT .

有些错误的安装程序会在开始时将已安装应用程序的文件夹路径添加到系统环境变量PATH 中,而不是在末尾附加,并且还包含在应用程序的文件夹中find.exefindstr.exe这是 Unix 的移植,因此与 find.exe 完全不同和 findstr.exe window 。 AVRStudio 是(或者可能未经过最新版本的 AVRStudio 验证)一个破坏 IT 管理员批处理文件的示例,在安装后未对 Windows 命令始终使用完整的文件名。

关于windows - FINDSTR 在从 Windows XP 到 Windows Server 2012 的所有 Windows 操作系统上的位置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31331819/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com