China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-03 22:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Question about inserting into each line View 805 Replies 5
Original Poster Posted 2007-03-24 11:27 ·  中国 福建 三明 电信
新手上路
Credits 18
Posts 7
Joined 2006-12-20 00:26
19-year member
UID 73981
Gender Male
Status Offline
How can I use a batch file to insert a piece of text at the beginning or end of each command line in another batch file

Thanks~~~
Floor 2 Posted 2007-03-24 11:28 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Could you give an example so we can take a look?
Floor 3 Posted 2007-03-24 12:19 ·  中国 福建 三明 电信
新手上路
Credits 18
Posts 7
Joined 2006-12-20 00:26
19-year member
UID 73981
Gender Male
Status Offline
I'm trying to add echo off to the beginning of the commands in each batch file (just as an example)

Add echo off before the following commands
sfc /purgecache
sfc /purgecache
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\*.log
del /f /s /q %windir%\*.tmp
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
rd /s /q %temp% & md %temp%
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"

Make it become:

echo off sfc /purgecache
echo off sfc /purgecache
............................................
Floor 4 Posted 2007-03-24 12:23 ·  中国 福建 三明 电信
新手上路
Credits 18
Posts 7
Joined 2006-12-20 00:26
19-year member
UID 73981
Gender Male
Status Offline
Or for
regsvr32 actxprxy.dll
regsvr32 shdocvw.dll
regsvr32 oleaut32.dll
Regsvr32 URLMON.DLL
add /s so it becomes
regsvr32 /s actxprxy.dll
regsvr32 /s shdocvw.dll
regsvr32 /s oleaut32.dll
Regsvr32 /s URLMON.DLL
Floor 5 Posted 2007-03-24 12:31 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Replying to the post above, you can try solving the problem in post #3 by following this example:

@echo off
del __new.bat 2>nul
for /f "tokens=1*" %%a in (test.txt) do (
echo %%a /s %%b>>__new.bat
)
start notepad __new.bat
Floor 6 Posted 2007-03-24 12:43 ·  中国 福建 三明 电信
新手上路
Credits 18
Posts 7
Joined 2006-12-20 00:26
19-year member
UID 73981
Gender Male
Status Offline
Thanks, I'll give it a try
Forum Jump: