Rem: Creating .ini Files

If you want to automate the process of creating .ini files, here are some of your scripting options.

Bob Wells

April 22, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Do you have a scripting-related question or problem? You can send your question or problem to [email protected].

I want to create .ini files by extracting server information from a database and inserting that information into a template. Initially, I wanted to use the GetPrivateProfileString and WritePrivate-ProfileString APIs with VBScript so that I could easily read and write to the .ini files without having to parse the extracted information. However, I discovered those APIs are inaccessible with VBScript code. Thus, I see my options as

  • don't use those APIs but instead use the Scripting Runtime Library's TextStream object and parse the extracted information

  • wrap the APIs into a scriptable Microsoft Visual Basic (VB) COM component

  • wrap the APIs into a Windows Script Components (WSC) object that uses Perl to access the Win32 API

  • find a shareware or freeware component

What do you recommend?

If you're not opposed to using Perl, the Win32::AdminMisc module provides ReadINI and WriteINI functions. You can download the module and find usage instructions at http://www.roth.net/perl/adminmisc.

If you don't want to use Perl, check out the wshadmin.dll and wshini.dll freeware components, which you can use with any Windows Script Host (WSH)-enabled scripting language. These components use the WriteProfileString API. You can find both components at http://cwashington.netreach.net/main_site/downloads/default.asp?topic=n-z.

Finally, if you want to create a parser from scratch, you can create a VBScript class that uses the Scripting Runtime Library's FileSystemObject object. For information about VBScript classes, see Dino Esposito, "Importing and Porting Classes in VBScript 5.0," January 2000. For information about FileSystemObject object, see Dino Esposito, "Understanding VBScript: Manipulating Files with FileSystemObject," January 2000.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like