![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Read config file I'm working on a script that will read in configuration information and perform actions based on that. Is there a "best practice" for doing this? Essentially, I'd like to read in things like database name, input file locations, output file locations, etc. Should I use INI, XML, something else? |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Read config file What is the configuration file for? is it an application you are writing. Different applications have different config files so its difficult to generalise. if you are writing the app I would suggest using XML -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "sylan" wrote: Quote: > I'm working on a script that will read in configuration information and > perform actions based on that. > > Is there a "best practice" for doing this? Essentially, I'd like to read in > things like database name, input file locations, output file locations, etc. > Should I use INI, XML, something else? |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Read config file The standard for .net applications is an xml file named after the exe, with a ..config suffix. For example, the config for hello.exe would be hello.exe.config. The outer elements and some inner elements are standardized, but the format can also be extended in a specified manner. The System.Configuration.ConfigurationManager namespace of the framework contains classes that support reading and writing such config files, and you can of course call those methods from Powershell. While you don't have an exe and thus won't get some of the automagic that comes from the exe.config association, you could still follow that format and use methods of the ConfigurationManager class to access a file with a name like "myscript.ps1.config". Even if you don't want to use the standard format for the content, I think using xml and that .config naming convention would be a good idea. - leo "sylan" wrote: Quote: > I'm working on a script that will read in configuration information and > perform actions based on that. > > Is there a "best practice" for doing this? Essentially, I'd like to read in > things like database name, input file locations, output file locations, etc. > Should I use INI, XML, something else? |
My System Specs![]() |
| | #4 (permalink) |
| | RE: Read config file That's what I needed. Thanks! "Leo Tohill" wrote: Quote: > The standard for .net applications is an xml file named after the exe, with a > .config suffix. For example, the config for hello.exe would be > hello.exe.config. The outer elements and some inner elements are > standardized, but the format can also be extended in a specified manner. > The System.Configuration.ConfigurationManager namespace of the framework > contains classes that support reading and writing such config files, and you > can of course call those methods from Powershell. > > While you don't have an exe and thus won't get some of the automagic that > comes from the exe.config association, you could still follow that format and > use methods of the ConfigurationManager class to access a file with a name > like "myscript.ps1.config". > > Even if you don't want to use the standard format for the content, I think > using xml and that .config naming convention would be a good idea. > > - leo > > > "sylan" wrote: > Quote: > > I'm working on a script that will read in configuration information and > > perform actions based on that. > > > > Is there a "best practice" for doing this? Essentially, I'd like to read in > > things like database name, input file locations, output file locations, etc. > > Should I use INI, XML, something else? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| config file problems | PowerShell | |||
| what is the web.config file? | Vista General | |||