批处理-在没有for命令的情况下从配置文件中读取lines/var [英] batch - Reading lines/var from config file without for command

查看:67
本文介绍了批处理-在没有for命令的情况下从配置文件中读取lines/var的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以在没有for /f或任何for的情况下从config/txt文件中读取行吗? 无论如何,我想拥有一个确定提示颜色的配置文件. 我有以下批处理代码:

Can you read lines from a config/txt file without the for /f or any for? Anyways, I wanted to have a config file what determines the color of the prompt. I have the following batch code:


@echo OFF
color %color%
@echo
cmd

和此.config文件:

and this .config file:

---------type color here----------
a 

预期输出:

color a

然后

set /p color<main.config

仅读取文件的第一行.

推荐答案

假设您拥有文件1.bat(批处理)和1.config(configfile) 如果您确实不想使用for命令,则可以执行此操作.

assuming you have your files 1.bat (your batch) and 1.config (configfile) you can do this if you really dont want to use the for command.

@echo OFF
findstr /V "#" 1.config >1.tmpcfg
set /p COL= < 1.tmpcfg
del 1.tmpcfg
color %COL%
cmd

但是我更喜欢使用'for'...
:-)

But I'd prefer using 'for'...
:-)

这篇关于批处理-在没有for命令的情况下从配置文件中读取lines/var的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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