Computing.Net > Forums > Programming > Execute command based on txt file contents

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Execute command based on txt file contents

Reply to Message Icon

Name: AudioFox
Date: July 10, 2009 at 21:04:53 Pacific
OS: Windows Vista
Subcategory: Batch
Comment:

I have a text file that some times has "Cisco
VPN adapter" in it. My goal is to execute a
command based on if it is there or not. I need
this to work in dos the goal is to turn off a
service when the string is detected and turn on
the service if the string is not detected. i have
worked hard on the first half of the code and
just need help with this second half. trying to
do this all in NT DOS batch. Thanks in
advance!



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 10, 2009 at 23:33:50 Pacific
Reply:

@echo off & setLocal EnableDelayedExpansion

find "CiscoVPN adapter" < myfile > nul
if errorlevel 1 (
echo turn on
) else (
echo turn off
)


=====================================
If at first you don't succeed, you're about average.

M2


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Execute command based on txt file contents

Batch deletion based on .txt file on ftp www.computing.net/answers/programming/batch-deletion-based-on-txt-file-on-ftp/20025.html

copy or move files based on file extensions www.computing.net/answers/programming/copy-or-move-files-based-on-file-extensions/20072.html

Batch file: rename file based on fs www.computing.net/answers/programming/batch-file-rename-file-based-on-fs/16792.html