• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Using Delayed Environment Variable Expansion

Using Delayed Environment Variable Expansion

The FOR command is an excellent tool for understanding the delayed environment variable expansion that I discussed in Appendix B. To refresh your memory, if you start the cmd.exe with the /V:ON switch, you turn on delayed environment variable expansion, which means that Windows Vista doesn’t expand a particular environment variable within a batch file until it executes the statement containing that variable.

For example, suppose that you want to use FOR to display a list of subfolder and files in the current folder. You might think that you could loop through all the items in the folder and store each one in a custom environment variable. Here’s a first pass:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint