Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Batch file issues


(!)

lammv's Avatar
lammv lammv is offline
Member with 10 posts.
THREAD STARTER
 
Join Date: Aug 2012
30-Aug-2012, 11:23 AM #1
Batch file issues
Hello there.
I 'm trying to solve one issue.

1. I have a file names.ini. The end of the file is:

Code:
FOV=15
[Network] 
Networkline=default
Here I need to change FOV and two last lines leave the same. So I use the FINDSTR.
The easiest way for me is finding lines which contain words " network fov", delete them and then add to the file following lines


Code:
echo FOV=%m% >> names.ini
echo [Network] >> names.ini
echo Networkline=default >> names.ini
so. FIND and DELETE.

I've found how to FIND

Code:
sc query | findstr /i "network fov" names.ini  ?????
how to delete the founded lines?

2. And for sure.
what is the command here just replacing FOV with its new value

Code:
sc query | findstr  "FOV" names.ini  ?????
how to replace the founded line by the new FOV's value?
3. Also I have a line in the names.ini file
NAME=changed_username

I can find it by means of the line too.
But how can I read it and use it in my next operations?


Code:
sc query | findstr "FOV" names.ini   ????
Squashman's Avatar
Trusted Advisor with 19,648 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
22-Sep-2012, 05:12 PM #2
Well your syntax isn't even close if you were using quarter stick of TNT to try and accomplish this task.

Let me see the output of
Code:
sc query | findstr /C:"FOV"
lammv's Avatar
lammv lammv is offline
Member with 10 posts.
THREAD STARTER
 
Join Date: Aug 2012
16-Oct-2012, 06:41 AM #3
Can you be more specific, because the issue doesn't work so far.
I brought up 3 questions.
Can I get back 3 lines of your answers?
Thank you.
Squashman's Avatar
Trusted Advisor with 19,648 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
16-Oct-2012, 07:56 AM #4
I can't answer any of your questions until you show me the output of
Code:
sc query | findstr /C:"FOV"
From what I understand you are trying to update the "names.ini" file with output from the "SC QUERY" command.

If you cannot answer my questions then I cannot answer yours.
bliss-II's Avatar
bliss-II   (Charlie) bliss-II is offline
Member with 33 posts.
 
Join Date: Oct 2012
Experience: Advanced
19-Oct-2012, 10:31 PM #5
Code:
sc query | findstr /c:"FOV" >> tempfile
for /f "skip=1 tokens=1" %%a in (names.ini) do echo %%a >> tempfile
del names.ini
ren tempfile names.ini
The FOR loop basically skips the first line and dumps the rest into tempfile.

The rest should be self-explanatory.
foxidrive's Avatar
foxidrive foxidrive is offline
Member with 647 posts.
 
Join Date: Oct 2012
Experience: Advanced
20-Oct-2012, 05:06 AM #6
This should do it too and uses GNUsed for Windows.

It expects that FOV=NNN only appears once in the output from SC query and it is designed to replace the entire line when FOV= appears in the first column of names.ini

I can't check the format of FOV=NNN from sc query as it doesn't appear on my machine.

Code:
@echo off
for /f "delims=" %%a in ('sc query ^| findstr /c:"FOV"') do (
sed "s/^fov=.*$/%%a/I" names.ini >names.ini.tmp
)
move /y names.ini.tmp names.ini
Thanks to squashman for pointing out the forum - another one for me to play in.

Last edited by foxidrive; 20-Oct-2012 at 07:12 AM..
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑