我需要一个批处理文件“master.bat”,在执行时会创建一个带有给定doce的新批处理文件“children.bat”: 代码是
@echo off
“pre.txt”(for / f“tokens = 3,4”%% a in( '净统计工作站^ |找到“自” )做( echo %% a %% b )) 出口
答案 0 :(得分:0)
创建包含该代码的新批处理文件:
只需echo
代码并将其发送到您想要的文件(>
)
echo @echo off "pre.txt" (for /f "tokens=3,4" %%a in ( 'net statistics workstation ^| find "since"' ) do ( echo %%a %%b )) exit > mybat.bat
以恰当的方式运行该代码:
for /f "tokens=3,4" %%a in ( 'net statistics workstation ^| find "since"' ) do ( echo %%a %%b >> pre.txt )
创建并运行批处理文件
echo @echo off > children.bat
echo for /f "tokens=3,4" %%%%a in ( 'net statistics workstation ^^^| find "since"' ) do ( echo %%%%a %%%%b ^>^> pre.txt ) >> children.bat && children.bat
答案 1 :(得分:0)
@echo off
title Just a sandbox test
color f
:start
cls
set "file=%userprofile%\Desktop\children.bat
(
echo ^@echo off
echo ^"pre.txt^" ^(for /f ^"tokens=3,4^" ^%^%a in ^( ^'net statistics
workstation ^^^| find echo ^"since^"^' ^) do ^( echo ^%^%a ^%^%b ^)^) exit
) >%file%
::rest of your code goes here I guess
pause
刚刚测试过,这将有效。在通常与语法冲突的字符之前添加^将强制脚本忽略它。 :)
聚苯乙烯。对不起,有点晚了哈哈