Bits has some advantages, Namely you can throttle it using a GPO
Be warned it has a number of disadvantages, no COM interface, it self throttles 
2 seconds after it detects other traffic which can be annoying

This nearly worked…

I had to deploy to about 80 laptops on intermittent connections
The idea was to have 2 kinds of package…
PACKAGE: Deploy_acrobat runs once and triggers BITS. Detects if a zip file 
exists at the end
PACKAGE: Install_Acrobat depends on Deploy_acrobat, has 2 commands… unpacks the 
zip and runs to contained setup.bat

A single Samba share was setup with all the packages 
(\\apps\packages<file:///\\apps\packages>)
This is used to list the contents
Apache ran with virtualhost pointing to the same directory
BITS transfers files using http
Bitsadmin.exe was used as you cannot script BITS unless you use powershell 
(which machines didn’t have)

Each directory was compressed using 7zip into 2mb split archives (bitsadmin 
doesn’t allow partial transfers) and put into a directory \deploy\
Names of folders, packages etc are kept uniform

Below is the wrapper for the BITSadmin. It uses 2 tools bitsadmin.exe and 
psexec.exe
Note is a proof of concept and doesn’t handle multiple downloads
<code>
if [%1] == [] (
   echo "Usage: bitsadmin.bat PACKAGENAME"
   exit /B
  )

SET PACKAGE=%1

:: Remember CASE SENSITIVE!
:: \deploy folder should contain 7z files to be extracted
:: get bitsadmin
if NOT EXIST %WINDIR%\system32\bitsadmin.exe copy /y 
\\apps\system\tools\bitsadmin.exe %WINDIR%\system32\
if NOT EXIST %WINDIR%\system32\psexec.exe copy /y 
\\apps\system\tools\psexec.exe %WINDIR%\system32\

:: runs bitsadmin as system account
SET BITSCOMMAND=psexec -i -s %WINDIR%\system32\bitsadmin.exe
SET URL=http://apps.site.com/

:: Deals with BITS In Progress by exiting
for /F %%I in ('c:\windows\system32\bitsadmin.exe  /getcompletiontime 
%package%') do (
  if /I %%I==WORKING (
   exit /B
  )
)
:: Cancel anything outstanding
for /F "tokens=1,2,3" %%I in ('c:\windows\system32\bitsadmin.exe /rawreturn 
/list /allusers') do (
    c:\windows\system32\bitsadmin.exe /rawreturn /cancel %%I
    )

:: Add the job
for /F %%I in ('c:\windows\system32\bitsadmin.exe /RAWRETURN /CREATE /DOWNLOAD 
%PACKAGE%') do set GUID=%%I
:: Take ownership (as system)
%BITSCOMMAND% /TAKEOWNERSHIP %GUID%
:: Add all the files for this package from the SMB folder of the same name
for /F %%I in ('dir /b \\apps\packages\%package%\deploy\') do %BITSCOMMAND% 
/RAWRETURN /ADDFILE %GUID% %url%/%package%/deploy/%%I 
%windir%\temp\%package%\%%I
:: when complete run complete command
%BITSCOMMAND% /RAWRETURN /SETNOTIFYCMDLINE %GUID% "%BITSCOMMAND%" 
"c:\windows\system32\bitsadmin.exe /RAWRETURN /COMPLETE %GUID%"

%BITSCOMMAND% /SETPROXYSETTINGS %GUID% PRECONFIG

:: START
%BITSCOMMAND% /RESUME %GUID%
</code>

At the end of the day I realised that the complexity of getting bits to run 
wasn’t really worth the effort. I could achieve the same results with a single 
package
Transferring the data using ROBOCOPY (aka poor mans rsync)
Unzipping the contents
Running setup.bat

I dynamically set the IPG (interpacket gap) for robocopy using this neat js for 
gateway detection

<code js>
var tsv =/^10\.10\.[0-7]\./i;
var mky =/^10\.10\.14\./i;
var rok =/^10\.10\.13\./i;
var cns =/^10\.10\.12\./i;
var cba =/^10\.10\.11\./i;
var nextg =/^10\.10\.10\./i;
var gap = 0;
// Sets IPG for robocopy to use based on location
// set IPG to 'exit' if not required
var IPG = getIPAddresses();
WScript.Echo(IPG);
function getIPAddresses() {
       var wmi = GetObject("winmgmts:!\\\\.\\root\\cimv2");;

       var nic = wmi.ExecQuery("Select * from Win32_NetworkAdapterConfiguration 
Where IPEnabled = True");
var e= new Enumerator(nic);
       for (; !e.atEnd(); e.moveNext()) {
                           var x = e.item().ipAddress(0);
                           if ( nextg.test(x)) {gap = 1000;}
        if ( tsv.test(x)) {gap = 0; break;}
                           if ( mky.test(x)) {gap =  200; break;}
                           if ( rok.test(x)) {gap =  200; break;}
                           if ( cns.test(x)) {gap =  200; break;}
                           if ( cba.test(x)) {gap =  500; break;}
                     }
       return(gap);
}
</code>

The other alternative would be DFS-R (server 2003 R2 and up)
http://blogs.technet.com/b/filecab/archive/2006/06/14/434190.aspx


Michael Chinn
PC Support Office
Information and Communications Technology
Great Barrier Reef Marine Park Authority
2-68 Flinders Street
PO Box 1379
Townsville Qld 4810

Ph:    07 4750 0855
Fax:   07 4772 6093
email: michael.ch...@gbrmpa.gov.au

Visit us at: http://www.gbrmpa.gov.au
=============================================================================
If you have received this transmission in error please notify us immediately
by return email and delete all copies. Any unauthorised use, disclosure or
distribution of this email is prohibited.
=============================================================================

From: wpkg-users-boun...@lists.wpkg.org 
[mailto:wpkg-users-boun...@lists.wpkg.org] On Behalf Of Sean Kennedy
Sent: 29 December 2010 14:25
To: wpkg-users@lists.wpkg.org
Subject: [wpkg-users] Using BITS to transfer files?

I'm just wondering if anyone has ever taken a look at using BITS to transfer 
files to the client?  Having recently started a new job where I have 250+ sites 
that I would love to use WPKG on, I have run up against a bandwidth problem; 
the sites are all 128k or lower bandwidth.  I got around this problem with 
windows updates by utilizing BITS ( built in to windows since...2000?  I think 
), and it got me thinking that it would be awesome if wpkg could use the built 
in BITS functionality as well.

Is this one of those things that was looked at but decided against?  How else 
has everyone solved the bandwidth problem?
-------------------------------------------------------------------------
wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
_______________________________________________
wpkg-users mailing list
wpkg-users@lists.wpkg.org
http://lists.wpkg.org/mailman/listinfo/wpkg-users

Reply via email to