Delen via


Bitsadmin script

Attached is a script that I wrote to automate downloading a large file (e.g., ISO, WIM) by using BITS.  There are variables at the start that need to be updated with the URL from which to download the file(s), and then the file name(s).  If only one file is needed, remove the strFile2 variable as well as the second "adding file" section.  If more than two files are needed, add a strFile3 and another "adding file" section.  The script assumes that the file type is properly registered with IIS, and it is secured using integrated windows authentication.  Using /setcredentials with the negotiate parameter and then "null" for both the username and password allows BITS to use implicit (pass-through) authentication of the currently logged on user.  Then no credentials are gathered from the user, and the logon occurs via Kerberos.

Rename the attached file with a .cmd extension.  The script is written to have bitsadmin.exe in the same directory as the script; I was using vv6.6.3790.3959 from the Windows Server 2003 SP2 Support Tools.  To make it easier to distribute the script and executable, I just zipped them together and made them available on the same web server but in a non-secure virtual directory.

The script will wait (with no progress) until the status of the transfer shows as "TRANSFERRED".  So to show better status (or ensure there are no errors), open another command prompt window and run bitsadmin /monitor.  If an error occurs, run bitsadmin /geterror jobname to see the details. NOTE:  BITS job names are case sensitive.

If things go horribly wrong, you can enable BITS logging to get more detail.

reg add HKLM\Software\Microsoft\Windows\CurrentVersion\BITS /v LogFileFlags /t REG_DWORD /d 0xfbcf /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\BITS /v LogFileSize /t REG_DWORD /d 0x100 /f
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\BITS /v LogFileMinMemory /t REG_DWORD /d 0x30 /f
net stop bits
net start bits

I'd recommend using reg query on those keys and values first to determine the previous data so you can reset them when done troubleshooting.

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

BITSDownload-jobname-v1.txt

Comments

  • Anonymous
    January 01, 2003
    Microsoft’s Background Intelligent Transfer Service (BITS) has been around since Windows 2000 SP3 and