MS-DOS "plugin" 系统?
MS-DOS "plugin" system?
创建一个名为Joker.cmd(https://github.com/nightmare-dll/Joker/)的程序,基本上就完成了。基本上是我首先测试了 github,然后变成了我不介意完全发布的东西。
基本搞定了,很想实现一个用户插件系统。目录树截至目前(未在 github 上同步);
data/
-config.cmd
plugins/
- test1.cmd
- test2.cmd
joker.cmd
那么 joker.cmd 会同时列出 "test1.cmd" 和 "test2.cmd" 并且有一个
set /p plugin=Plugin name;
start %plugin%.cmd
然后运行指定的插件。
唯一的问题是如何让 joker.cmd 仅列出以 .cmd 或 .bat 结尾的文件?
如何让 joker.cmd 仅列出以 .cmd 或 .bat 结尾的文件?
将以下行自动添加到 joker.cmd 到 运行 插件中:
for /f "tokens=*" %%f in ('dir /b plugins\*.cmd plugins\*.bat') do (
start "" %%f
)
将以下行添加到 joker.cmd 以提示插件到 运行:
dir /b plugins\*.cmd plugins\*.bat
set /p plugin=Plugin name:
start "" plugins\%plugin%
注:
Always include a TITLE this can be a simple string like "My Script"
or just a pair of empty quotes ""
According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.
来源start
进一步阅读
- An A-Z Index of the Windows CMD command line - 所有与 Windows cmd 行相关的内容的绝佳参考。
- dir - 显示文件和子文件夹列表。
- for /f - 根据另一个命令的结果循环命令。
- start - 启动程序、命令或批处理脚本(在新 window 中打开)。
创建一个名为Joker.cmd(https://github.com/nightmare-dll/Joker/)的程序,基本上就完成了。基本上是我首先测试了 github,然后变成了我不介意完全发布的东西。
基本搞定了,很想实现一个用户插件系统。目录树截至目前(未在 github 上同步);
data/
-config.cmd
plugins/
- test1.cmd
- test2.cmd
joker.cmd
那么 joker.cmd 会同时列出 "test1.cmd" 和 "test2.cmd" 并且有一个
set /p plugin=Plugin name;
start %plugin%.cmd
然后运行指定的插件。 唯一的问题是如何让 joker.cmd 仅列出以 .cmd 或 .bat 结尾的文件?
如何让 joker.cmd 仅列出以 .cmd 或 .bat 结尾的文件?
将以下行自动添加到 joker.cmd 到 运行 插件中:
for /f "tokens=*" %%f in ('dir /b plugins\*.cmd plugins\*.bat') do (
start "" %%f
)
将以下行添加到 joker.cmd 以提示插件到 运行:
dir /b plugins\*.cmd plugins\*.bat
set /p plugin=Plugin name:
start "" plugins\%plugin%
注:
Always include a TITLE this can be a simple string like
"My Script"
or just a pair of empty quotes""
According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.
来源start
进一步阅读
- An A-Z Index of the Windows CMD command line - 所有与 Windows cmd 行相关的内容的绝佳参考。
- dir - 显示文件和子文件夹列表。
- for /f - 根据另一个命令的结果循环命令。
- start - 启动程序、命令或批处理脚本(在新 window 中打开)。