viewtopic.php?f=3&t=2597
There was some interesting discussion here about how the system behaves when a new variable is set. I was wondering if anyone has any suggestions on how best to improve performance in a script that is meant to capture system information into hundreds of variables and echo them to the console and to file. A very very brief example of the type of thing I am doing for a very basic idea:
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%e in ('wmic timezone get caption 2^>nul^|findstr /r [a-z]^|findstr /v "Caption"') do for /f "tokens=*" %%f in ("%%e") do set "tZone=%%f"
for /f "tokens=*" %%g in ('whoami 2^>nul') do set "whoAM=%%g"
set "ePath=%userprofile%\sys_info.txt"
cls
echo Time Zone: !tZone!
echo User Name: %whoAM%
(
echo Time Zone: !tZone!
echo User Name: %whoAM%
) > %ePath%
pause > nul
Edit: For what it's worth, I did try this with a negligible performance benefit:
Code: Select all
for /F "tokens=1 delims==" %%v in ('set') do if /I not "%%v"=="PATH" set "%%v="