1,输出批处理内的字符到文件,变量不被扩展:- @echo off
- >c:\hello.bat more 3+<"%~f0"
- exit
- helo1>2
- ello%n%
- echo hello!n!
- good
复制代码 2,输出批处理内的字符到文件,包含被扩展的变量值(只有!n!被扩展):- @echo off&setlocal enableDelayedExpansion
- set n=123
- (for /f "delims=" %%a in ('more +4^<"%~f0"') do echo;%%a)>c:\hello.bat
- exit
- helo1^>2
- ello%n%
- echo hello!n!
- good
复制代码 3,输出批处理内的字符到文件,包含被扩展的变量值(!n!和%n%都被扩展):- @echo off&setlocal enableDelayedExpansion
- set n=123
- (echo;helo1^>2
- echo;ello%n%
- echo;echo hello!n!
- echo;good)>c:\hello.bat
复制代码
[ 本帖最后由 hanyeguxing 于 2011-2-1 19:25 编辑 ] |