Make Batch Files Run from Network Shares Execute More Quickly

Batch files are read a line at a time, so if over a slow
network file, and the batch file is long or using for loops it can take ages to
execute. Put this at the beginning of your batch files so that it will detect if
they are being excecuted from a network share, if so it will copy the file to
local temp folder then execute it.

SET UNC=%UNC:~1,2%
“\\” (
echo Too slow running from network ~ copying to %temp%\%~n0%~x0

xcopy %0 “%temp%” /d /y
cmd /c “%temp%\%~n0%~x0”
echo Running Locally…

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Batch Files. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s