Solved

Bacth Script to Add Lines to notes.ini file

Posted on 2008-10-28
3
768 Views
Last Modified: 2013-11-10
I need to find a script that will do the following:

1. Look for the notes.ini file either in C:\Data\Notes or H:\Data\Notes
2. Check if the following variables exist and if note append to the end of the file:
      EXTMGR_ADDINS=mc.dll
      MC_DB=DOM-01!!ClientUpdate\update.nsf

Any help is much appreciated.
             
0
Comment
Question by:zmannan83
3 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
Comment Utility
Paste the script below into a text file with a .cmd extension.  Running it will append the parameters to the file if they are not already defined.


@echo off

setlocal enabledelayedexpansion
 

for /F "tokens=*" %%G in ('type C:\Data\Notes\notes.ini') do (

 set line=%%G

 if /I "!line:~0,14!"=="EXTMGR_ADDINS=" set found1=true

 if /I "!line:~0,6!"=="MC_DB=" set found2=true

)
 

if not defined found1 echo EXTMGR_ADDINS=mc.dll>>C:\Data\Notes\notes.ini

if not defined found2 echo MC_DB=DOM-01!!ClientUpdate\update.nsf>>C:\Data\Notes\notes.ini
 

set found1=

set found2=
 

for /F "tokens=*" %%G in ('type H:\Data\Notes\notes.ini') do (

 set line=%%G

 if /I "!line:~0,14!"=="EXTMGR_ADDINS=" set found1=true

 if /I "!line:~0,6!"=="MC_DB=" set found2=true

)
 

if not defined found1 echo EXTMGR_ADDINS=mc.dll>>H:\Data\Notes\notes.ini

if not defined found2 echo MC_DB=DOM-01!!ClientUpdate\update.nsf>>H:\Data\Notes\notes.ini

Open in new window

0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Only issue you may have is that the notes.ini file can sometimes have < > and | characters in it which tend to break batch type entries like above as I've found myself in the past.  I would suggest either using VBScript or possibly taking a different approach and using find to check if the entries are there then just append them:

@echo off
set inifile=C:\lotus\notes65\notes.ini
find /I "EXTMGR_ADDINS=mc.dll" "%inifile%"  
if errorlevel 1 echo "MC.DLL addin entry not found" & echo EXTMGR_ADDINS=mc.dll>>%inifile%

find /I "MC_DB=DOM-01!!ClientUpdate\update.nsf" "%inifile%"  
if errorlevel 1 echo "MC_DB entry not found" & echo MC_DB=DOM-01!!ClientUpdate\update.nsf>>%inifile%

Steve
0
 

Author Closing Comment

by:zmannan83
Comment Utility
There was an issue with using the ! symbol, which was overcome by using ^ character
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now