Modify .ini files to reflect system-side updates with this admin script
Takeaway: TechRepublic asked members to submit their favorite Network Administration scripts. You can use this script to modify a .ini file.
TechRepublic recently asked members to submit their favorite Network Administration scripts for possible publication. One of the first to make a submission was Kurt Hudson. For his effort, Kurt earned $100 and the satisfaction of seeing his script published on the Internet.
Earn $100 for your admin script
Let us pay you for your original scripts so that we can publish them as downloads on TechRepublic and allow your fellow IT professionals to benefit from your scripting savvy. We only ask that you put in the appropriate comments to your scripts so that it's easy to tell what the script is doing and which variables might need to be customized. Send us your original Windows admin scripts and we'll pay you $100 for each one that we publish as a TechRepublic download.
Here in his own words and code is Kurt's admin script:
I developed this script (Listing A) to help a network administrator colleague to modify the Lotus Notes notes.ini file for all of the client computers in his enterprise network. The script was distributed through Group Policy as a startup script to ensure that all client computers would have their .ini files updated to reflect a new notes database that my colleague created.
I originally did not comment any of my code, but I just spent a little while explaining almost every line or section in this file. I think this will be educational and useful for network administrators who need to modify system files (especially for programs that still rely on .ini files). I hope you agree.
Listing A
' This is an example script that can be used to modify an ini file in
' a Windows client operating system. I developed this script to modify
' the Notes.ini. However, it could be used to modify any file on a
' client computer.
' Defining constants - meaningful names that replace values
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
' Declaring variables that are used to perform functions in later lines
Dim orgfile, newfile, fs, strLine
' Setting variables to perform built in functions
' The variable fs will be set to create a file system object
set fs = CreateObject("Scripting.FileSystemObject")
' The variable orgfile is used to open the existing notes.ini file
set orgfile = fs.OpenTextFile("notes.ini")
' The variable newfile is used to create a new file names notes.tmp
' This file will create a notes.tmp file that has the existing values
' in the current notes.ini file as well as the replacement values
' that I need in the new notes.ini so this will become the new notes.ini
set newfile = fs.CreateTextFile("notes.tmp")
' Copies the existing notes.ini file to a new file named notes.old
fs.CopyFile "notes.ini", "notes.old"
' The following section reads the entire notes.ini file looking for
' the NAMES section and replaces it with a new text stream
Do while not orgfile.AtEndofStream
strLine = orgfile.ReadLine
select Case strLine
case "NAMES=names.nsf, mdc.nsf, itcontacts.nsf"
newfile.WriteLine "NAMES=names.nsf, newmdc.nsf, itcontacts.nsf"
case else
newfile.WriteLinestrLine
end select
' the loop statement causes this section run until the entire file is evaluated
loop
' the following statements close the original and new files
orgfile.close
set orgfile = nothing
newfile.close
set newfile = nothing
' Remove the existing notes.ini
fs.DeleteFile "notes.ini"
' Rename the notes.tmp file notes.ini to make it the new notes.ini file
fs.MoveFile "notes.tmp", "notes.ini"
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- The Case for Virtual Local Area Networks (VLANs) Global Knowledge
- 2008 IT Salary and Skills Report Global Knowledge
- Eleven Myths about 802.11 Wi-Fi Networks Global Knowledge
- Simple Tricks to Ace the Subnetting Portion of Any Certification Exam Global Knowledge
- Preparing for and Taking the PMP Certification Exam Global Knowledge
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET

