Searching a specific word
suppose i want to search a specific word in the autoexec.bat or any file how can I achieve that through scripting
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
usachrisk
20 years ago
Depends on what you're scripting with, what OS you're running on, and what you want to do with the output. If you're doing a batch file or another script that will run at a command line, you can use the FIND command. An example could be:
@echo off
cls
FIND C:\MYFILE.TXT "CHRISTOPHER"
IF %ERRORLEVEL% == 0 GOTO FOUND
echo Sorry, couldn't find CHRISTOPHER in C:\MYFILE.TXT
goto end
:FOUND
echo Found CHRISTOPHER in C:\MYFILE.TXT!
:end
If you're using the SMS Installer, there is the script item that will read a file, and the one that can parse a string variable that would do the trick. The list goes on.
Chris.
@echo off
cls
FIND C:\MYFILE.TXT "CHRISTOPHER"
IF %ERRORLEVEL% == 0 GOTO FOUND
echo Sorry, couldn't find CHRISTOPHER in C:\MYFILE.TXT
goto end
:FOUND
echo Found CHRISTOPHER in C:\MYFILE.TXT!
:end
If you're using the SMS Installer, there is the script item that will read a file, and the one that can parse a string variable that would do the trick. The list goes on.
Chris.
Posted by:
guard
20 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.