Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 994427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:34:29+00:00 2026-05-16T06:34:29+00:00

I am trying to create a simple batch file that will replace a line

  • 0

I am trying to create a simple batch file that will replace a line in a text file with a different line, but keep every other line in the file the same. I found a script somewhere on the internet which I modified slightly and came up with the following code. However, for some reason this code is not echoing any lines ending in “=0” to the new text file as it should be, and is instead echoing them to screen (even with echo off). Does anyone have any suggestions?

Thanks much.

@echo off
if exist prod.ini del new_prod.ini
for /f "tokens=*" %%a in (prod.ini) do call :AddText "%%a"
del prod.ini
rename new_prod.ini prod.ini
exit /b

:AddText %1
@echo on
echo %1
@echo off
set Text=%~1%
if "%Text%"=="server=server-2.domain.com" (
echo server=server-3.domain.com>> new_prod.ini
) else (
echo %~1%>> new_prod.ini
)
exit /b

The original file has some lines like those that follow, but the new file after the script has left out these lines. The script works exactly as expected on the replace, as well as on 20 or so other lines. Only the lines that look as follows cause problems.

_sflag=0
debug_lvl=0
sel_test_lvl=0
ipc_error_logging_lvl=0
ipc_client_debug_lvl=0
ipc_server_debug_lvl=0

Thanks again.

edit: This will be run on hundreds of computers in the organization and using 3rd party tools is not really an option, as installing another application on all machines (even though theoretically possible with the remote management software we will use) is not desired.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:34:29+00:00Added an answer on May 16, 2026 at 6:34 am

    Instead of trying to search and replace using script commands, how about using a command line tool to do the same thing? It’s easier and faster (and works), and you can script it too. Google has a ton of them, for example, SSR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The C# compiler doesn't do much at all - it… May 16, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer String mixins can access the namespace they're mixed into. That… May 16, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer CustomEventWatcher will need a reference to MainWindow, for example via… May 16, 2026 at 6:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to create a batch script for my Windows machine that loops
I am trying to create simple user registration form. I have an index.html file
I am trying to create a simple Hit Counter using Kohana3 and PHP. But
I am trying to create a simple login page in ASP.NET C# but am
Looking at creating a simple batch file for my app. My app needs some
I'm trying to create a simple stored procedure which I can use to write
I'm trying to create a simple report on an intranet site. Based on this
I'm trying to create a simple menu pop-up effect using anchors within a div
I'm trying to create a simple modal popup. I have the CSS done, and
I'm trying to create a simple qDebug-like class I can use to output debug

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.