How to speed up a batch script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Sounak@9434
Posts: 100
Joined: 16 Dec 2016 22:31

Re: How to speed up a batch script

#16 Post by Sounak@9434 » 30 Dec 2016 07:59

misol101 wrote:Another little speedup trick is to clear out all or almost all unused environment variables. I found that all my scripts got a 5-10% speedup by doing this. I found this trick in a script by einstein1969. Just remember to call setlocal first, otherwise the variables are deleted from your actual cmd envioronment.

Code: Select all

setlocal
for /F "tokens=1 delims==" %%v in ('set') do set "%%v="
...
endlocal

@misol101, cool, I didn't know about this syntax of set. But just assume what will happen if I don't use setlocal? Will all the variables like %PATH% Will still be blank after restarting cmd or situation would return to normal?

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: How to speed up a batch script

#17 Post by misol101 » 30 Dec 2016 09:02

After closing down the current cmd and restarting it you will get your variables back. To change variables permanently you have to go to Control Panel Settings->System->Advanced->Environment Variables

Post Reply