Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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