|07 Nov 2012||#1|
| || |
Batch Scripting: How to mix SETLOCAL with non-local?
I have a batch file, to be called like this:
It's purpose is to setup a few environment variables:
:: This is setvars.cmd
This just illustrates the general idea. The user of setvars.cmd is supposed to be only interested in the variables MYVAR1 and MYVAR2, but he also sees the temporary variables temp1 and temp2.
Ideally, I would use setlocal to make temp1 and temp2 invisible to the outside, but this doesn't work here, because it also would hide MYVAR1 and MYVAR2.
As a workaround, I could use a temporary file:
echo set MYVAR1=%temp1%4711%temp2%>tempfile.bat
echo set MYVAR2=%temp2%_%temp1%>tempfile.bat
but this looks overly complicated to me. Is there a simpler solution to my problem?
|My System Specs|
|Similar help and support threads for2: Batch Scripting: How to mix SETLOCAL with non-local?|
|How to run a batch file at logoff & some batch scripting help please||Backup and Restore|
|Need help with windows batch scripting to create game for blind child||General Discussion|
|Our Sites ||Site Links ||About Us ||Find Us |
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
All times are GMT -5. The time now is 07:12 AM.