1、你的问题之所以被忽略,是因为标题写的不够清晰明了(建议你仔细看一下置顶帖)。我建议这样写:批处理中如何生成以当前日期为内容的环境变量?2、你所给出的运行环境不够详细,例如你将在哪个系统下运行这个批处理文件,是纯dos,还是98,或者是2k/xp/2003?3、你的问题并不是很难解决的问题,但不同的环境需要用到不同的方法。在2k/xp/2003下,你直接就可以使用%date%环境变量来作为当前日期。使用Horst的varset 和lmod程序,也可以实现(这应该算是通用的方案,我在2003下测试通过):
varset d=date | lmod /L1 /B. -- > temp.bat
call temp.bat
del temp.bat
上述命令运行完后,d环境变量中保存的就是以yyyy-mm-dd格式存储的当前日期。
1. Your question was ignored because the title was not clear enough (it is recommended that you carefully read the sticky post). I suggest writing it like this: How to generate an environment variable with the current date as the content in batch processing?
2. The running environment you provided is not detailed enough. For example, under which system will you run this batch file, is it pure DOS, or 98, or 2k/xp/2003?
3. Your problem is not a very difficult one to solve, but different environments require different methods. Under 2k/xp/2003, you can directly use the %date% environment variable as the current date. Using Horst's varset and lmod programs can also achieve this (this should be considered a general solution, and I tested it under 2003):
varset d=date | lmod /L1 /B. -- > temp.bat
call temp.bat
del temp.bat
After the above command is run, the d environment variable will store the current date in the yyyy - mm - dd format.