Re: .ini file to read script values
From: Nic Roche (nicroche_at_hotmail.com)
Date: 03/09/05
- Next message: Steven Burn: "Re: working days between two calendar days"
- Previous message: Jerold Schulman: "Re: Re: LsaAddAccountRights"
- In reply to: wouter: ".ini file to read script values"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Mar 2005 22:58:02 +1000
> using a .ini file to hold the values which in turn can be
> read by my scripts. I.E:
XML is a natural for things like this.
With the MSXML Parser:
For reading - SelectSingleNode.
If a web app use FreeThreadedDOMDocument
if not use DOMDocument.
If you want to learn more code can be posted.
Nic Roche
"wouter" <anonymous@discussions.microsoft.com> wrote in message
news:5d6e01c52496$4764f460$a601280a@phx.gbl...
> Hi,
>
> I have created a few scripts for monitoring purposes that
> need input like hostname, logfile path name, etc. Instead
> of hardcoding all values into each script I thought about
> using a .ini file to hold the values which in turn can be
> read by my scripts. I.E:
>
> ********** start .ini file **********
> [hostname]
> myserver1
>
> [logfile path]
> C:\folder\logfiles
>
> ********** end .ini file **********
>
> The scripts use the following code to read the .ini file:
>
> ********** script example **********
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> strINIfile = "C:\folder\file.ini"
>
> ' Open INI file to retrieve string values
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile(strINIfile,
> OPEN_FILE_FOR_READING)
>
> Do Until objTextFile.AtEndOfStream
>
> strText = objTextFile.ReadLine
>
> If Instr(strText, "[hostname]") Then
> strLogPath = objTextFile.ReadLine
> End If
>
> If Instr(strText, "[logfile path]") Then
> strSchemaPath = objTextFile.Readline
> Exit Do
> End If
>
> Loop
>
> objTextFile.Close
>
> Set objTextFile = Nothing
> Set objFSO = Nothing
>
> ********** end script example **********
>
> This all works very nice, but to me it looks like a little
> bit of spaghetti-programming; does anyone know a nicer
> (more professional) way of achieving the same result?
>
> TIA,
> Wouter
- Next message: Steven Burn: "Re: working days between two calendar days"
- Previous message: Jerold Schulman: "Re: Re: LsaAddAccountRights"
- In reply to: wouter: ".ini file to read script values"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|