PiqueABoo Posted December 7, 2006 Posted December 7, 2006 Have an INI file with contents like: Alice=One2Three Bob=Four5Six I want to pick one entry e.g. Bob and put it in an environment variable. This works: for /f "usebackq tokens=2 delims==" %%i in (`findstr Bob file.ini`) do set Bob=%%i Took me a teensy while to arrive there having first failed with other approaches. Has anyone ever got "other approaches" to work or is this pretty much what you have to do?
OutToLunch Posted December 11, 2006 Posted December 11, 2006 That's pretty much exactly how I'd do it... What other approaches did you try? Would be interesting to see if there's anything which could be hacked around a bit another time.
plexer Posted December 11, 2006 Posted December 11, 2006 Simple and works seems like a winner to me. Ben
bossman Posted December 11, 2006 Posted December 11, 2006 So if tom, Dick and Harry each had their own variables would it work as good hehe
IanB Posted December 12, 2006 Posted December 12, 2006 Nice bit of code. I'm getting to grips with AutoIt - that has specific functions for reading / writing .INI files. I recommend it. Or you could use a separate initool.exe such as this:- http://www.jsifaq.com/SF/Tips/Tip.aspx?id=7373
PiqueABoo Posted December 13, 2006 Author Posted December 13, 2006 What other approaches did you try? Oh I had loads of fun trying and failing to pipe and redirect the output of 'find' or 'findstr' to 'set' etc. Suspect my heart is stuck in early DOS days because "for /f.." just feels more complicated.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now