windows - 覆盖 Windows cmd 内部命令

标签 windows command-line path

我正在使用一个程序,该程序使用 type 命令将文件内容通过管道传输到另一个程序,如下所示:

type test.txt | (another program)

这个命令在我的主程序中是硬编码的。问题是 type 命令在正斜杠方面有问题:

E:\babak\git\bin>type e:/babak/git/bin/test.txt
The syntax of the command is incorrect.

有没有一种方法可以用名为 type 的自定义应用程序覆盖 cmd 内部 type,它支持正斜杠,所以如果有人调用 type 在 cmd 中,调用自定义 type 应用程序?

最佳答案

您可以使用 doskey 覆盖 command.com 中的内部命令,例如在 win7 上

c:\> date
  The current date is: Mon 09/18/2017
   Enter the new date: (mm-dd-yy)

c:\>   @doskey date=c:\cygwin\bin\date.exe $*
c:\>   @doskey echo=c:\cygwin\bin\echo.exe $*     

c:\> date +%Y-%m-%d
2017-09-18

关于windows - 覆盖 Windows cmd 内部命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13321506/

相关文章:

linux - 创建一个较短版本的 bash 命令

linux - 使用不同用户的 SSH 登录,不显示当前路径

.net - 指定当前用户文件路径的方法

.net - 为什么我的程序不能从 Program Files 目录运行,但可以从其他任何地方运行?

c++ - 使用 C++ 连接到 PC 的设备检测

c++ - 添加需要管理员才能启动的程序

c++ - 使用 C++ 在 Windows 中配对蓝牙设备

linux - 从 usr/include 中删除一个文件?

php - Linux : Library to write ID3v2 data and cover art

algorithm - 是否有一种算法可以在有向有根树(树状结构)中找到最小成本路径?