WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DOS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Add REMark Lines to AUTOEXEC.BAT File

Keywords:      autoexec.bat REMarks

Question:

I need to edit the Autoexec.bat on my users systems. I want REMark some lines. I can open the file scan for the text to be replace, but how do I over write the line?

Answer:

Try this...
SearchString = "This is the text to find"
Dir = DirGet()

DirChange("c:\")

If FileExist("autoexec.xxx") Then
FileAttrSet("autoexec.xxx", "r")
FileDelete("autoexec.xxx")
EndIf

FileRename("autoexec.bat", "autoexec.xxx")

InputFile = FileOpen("Autoexec.xxx", "Read")
OutPutFile = FileOpen("Autoexec.bat", "WRITE")

Line = FileRead(InputFile)
While Line != "*EOF*"
If StrIndex (Line, SearchString, 1, @FWDSCAN) Then
CheckRem = StrUpper(StrSub(Line, 1, 3))
If CheckRem != "REM" Then
Line = StrCat("REM ", Line)
EndIf
EndIf
FileWrite (OutPutFile, Line)
Line = FileRead(InputFile)
EndWhile

DirChange(Dir) 

Article ID:   W12889
Filename:   How to Add REM lines to Autoexec.bat File.txt
File Created: 1999:04:15:16:50:20
Last Updated: 1999:04:15:16:50:20