Novell is now a part of Micro Focus

Replace Spaces in Environment Variables

Novell Cool Solutions: Trench
By Victor Markwart

Digg This - Slashdot This

Posted: 26 Apr 2000

Had a little problem the other day where someone wanted to redirect users' drive mappings into text files using something like:
map > %username%.txt
but it wasn't working because some of the 'username' environment variables had spaces in them, and you can imagine what problems that caused!

However, here is a workaround, a small DOS program called IOETTMCO.EXE which takes as its one and only parameter a string, enclosed in quotes, eg:
"map > %username%.txt"

Any spaces in the 'username' environment variable are replaced with '_' characters. If you feel that there is a requirement for replacement of spaces with a different character, please let me know. It should work for any environment variable. Note that before obtaining the environment variable from the system it is converted to uppercase because DOS doesn't like lowercase environment variables....

If you are wondering about the name, IOETTMCO is an acronym of Inherently Obvious Even To The Most Casual Observer, which it probably isn't, but it's probably better than calling it 'Fred.'

I think I've got all the (obvious) bugs out of it, but you may find that your mileage may vary.

Download IOETTMCO.

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Micro Focus