Windows Batch Script to Replace Environment Variables in a File

Posted by skb on Stack Overflow See other posts from Stack Overflow or by skb
Published on 2010-06-02T21:48:58Z Indexed on 2010/06/02 21:54 UTC
Read the original article Hit count: 579

Filed under:
|
|

Hi. I want to write a batch file that will take the contents of a file, and replace any environment variable references inside the file with the actual environment variable values. Is this possible? Basically, if a file had this:

%PROGRAM FILES%\Microsoft SQL Server\

then I would want the file contents to become:

C:\Program Files\Microsoft SQL Server\

after the batch script ran. This is just one example, but I want ALL environment variables to be expanded. Thanks in advance for any help!

© Stack Overflow or respective owner

Related posts about Windows

Related posts about script