Rem: Creating .ini Files

Do you have a scripting-related question or problem? You can send your question or problem to bobwells@win2000mag.com.

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.

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• The Microsoft
Technology Roadmap
• Office 365 Implementation
• Hyper-V Optimizing
• Windows 8 Deployment
and much more!

Come See Paul Thurrott & Rod Trent in Person!

Early Registration Now Open

Upcoming Training

Mastering System Center 2012

During over 6 hours of training you can join John Savill from your computer as he will walk you through the key components and capabilities of System Center 2012, what’s involved in using the components, and the benefit they can bring to your environment.

Register Now

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.