Click to Rate and Give Feedback
Related Articles
This is teh descriptionBla ...

Read more!

A tip on how to write amazing fast queries. ...

Read more!

Active Directory, why it rocks! ...

Read more!

You know what ...

Read more!

This Tip will explain how to send email from Exchange ...

Read more!

Also by this Author

Michael Murgolo

TechNet Magazine March • April 2006

...

Read more!

Michael Murgolo is back with an update to his Elevation PowerToys. You'll find enhanced Run as Administrator functionality that works with third-party scripting tools, a way to replace a handy Windows XP feature removed from Windows Vista, and many more useful tools.

Michael Murgolo

TechNet Magazine June 2008

...

Read more!

While User Account Control offers an important improvement in security, the ability to elevate permissions is essential for accomplishing certain administrative tasks and functions. Here are some Elevation PowerToys that make elevation more flexible and powerful.

Michael Murgolo

TechNet Magazine June 2007

...

Read more!

When you’re deploying thousands of Windows-based computers, configuring a single system and duplicating its hard drive (or system image) onto other corporate computers can save you a lot of time and free up IT resources.

Michael Murgolo

TechNet Magazine May • June 2006

...

Read more!

Popular Articles

Michael Murgolo is back with an update to his Elevation PowerToys. You'll find enhanced Run as Administrator functionality that works with third-party scripting tools, a way to replace a handy Windows XP feature removed from Windows Vista, and many more useful tools.

Michael Murgolo

TechNet Magazine June 2008

...

Read more!

The new version of SQL Server offers a host of new features and enhancements that promise to improve performance, increase security, and make life better for database administrators. Here’s an overview of the key changes and what you can expect from SQL Server 2008.

Randy Dyess

TechNet Magazine April 2008

...

Read more!

Windows Server 2008 and the new Windows Server Backup utility bring many changes and welcome enhancements to backing up. Here is an in-depth guide to backing up and restoring Active Directory in the new server OS.

Gil Kirkpatrick

TechNet Magazine May 2008

...

Read more!

With Windows Vista, changes to the OS kernel bring about advances in many areas, ranging from memory management to reliability to security. We kick off this series with a look at how the kernel delivers improvements in the areas of processes, threads, and I/O.

Mark Russinovich

TechNet Magazine February 2007

...

Read more!

Wikis offer a new, more flexible way to collaborate, promoting an unstructured approach to thinking and exchanging ideas. And MOSS 2007 makes it incredibly easy to implement wikis in your organization. Here’s what you need to know to start building and using wikis in the workplace.

Mauro Cardarelli

TechNet Magazine January 2007

...

Read more!

Our Blog

"For developers, one difficult problem in SQL Server is tracking what data has changed in a database. An even greater challenge is architecting a simple solution that doesn’t heavily impact workload performance and isn't difficult to create, implement, and manage. So why go to all the trouble to track changes? Is tracking changes really worth all this effort? Two commonly cited examples are to support updates to a data warehouse and to support the synchronization of heterogeneous, occasionally connected systems." ...

Read more!

Proxy authentication lets users perform a simple bind to an Active Directory Lightweight Directory Services instance but still have an association to an Active Directory account. This can be very useful: it gives developers full access to a user object without giving them access to the Active Directory account, and it allows products that require the X.500 format to be used with Active Directory. ...

Read more!

Have various workers in your company been showing up with questions about Macs? The odds of having a homogeneous network today are very unlikely. Macs are becoming increasingly popular and chances are if you don't already have some on your network, soon you will. 

Don't consider this a burden. This actually creates a fantastic opportunity for you as an IT professional. Instead of being an administrator who says "I don't ...

Read more!

In the era of Software-plus-Services, Web services play an important role because they decouple hosted back-end environments from on-premise front-end applications. Explore  how the SharePoint platform drives online collaboration, so that Office applications and add-ins can run on local workstations while Web ...

Read more!

Want to be proactive about preventing data loss? Enterprise rights management is the way to go. Discover how   the Microsoft Enterprise Rights Management solution can protect your organization's information from unauthorized access and use.

Read more!

Utility Spotlight Scripting Trouble-Free Downloads with BITS
Michael Murgolo

Download the code for this article: UtilitySpotlight2006_08.exe (158KB)

Many of us in Microsoft Consulting Services spend lots of time downloading large ISO files and virtual machine images from our primary file servers in Redmond, and it’s so frustrating to have those downloads fail when a wireless or remote access connection is dropped. And though tools like Robocopy and Xcopy can be used in restartable mode, they require manual restart after a machine restart. Fortunately, the Background Intelligent Transfer Service (BITS), which is built into Windows® XP, Windows Server™ 2003, and Windows Vista™ can help you easily manage file downloads. Software and update distribution products like Systems Management Server (SMS) 2003, Windows Server Update Services, and Windows Automatic Updates use BITS to transfer updates and software to computers with limited end-user disruption.
BITS is designed to have minimal impact on resources; it transfers files using leftover network bandwidth. So if you’re using 60 percent of your bandwidth for other tasks, BITS will only use up to the remaining 40 percent and no more. Even better, if you get disconnected or need to restart your machine, the file transfer does not have to be restarted; when the network connection is re-established, BITS continues where it left off.
You can download files with BITS using a command-line tool called the BITS Administration Utility (Bitsadmin), which is found in the Windows Support Tools. With Bitsadmin you can achieve "set-and-forget" downloading. In this column I’ll describe how you can use Bitsadmin with a sample VBScript to automate BITS jobs.

BITS and Bitsadmin Versions
How you use Bitsadmin depends on which version of BITS you have installed on your operating system. Figure 1 lists BITS versions and features as well as the location of the downloads.

Version Description of Features
Version 2.5
  • Added support for certificate-based client authentication for secure HTTP transports and custom HTTP headers.
  • Included in the Windows Vista and Windows Server “Longhorn” operating system. A redistributable will be available for the Windows Server 2003, Windows XP, and Windows 2000 SP3 operating systems from the Microsoft Download Center.
  • The version of %windir%\System32\QMgr.dll is 6.7.xxxx.xxxx.
Version 2.0
  • Added support for performing concurrent foreground downloads, using server message block (SMB) paths for remote names, downloading ranges of a file, changing the prefix or complete name of a remote name, and limiting client bandwidth usage.
  • Included in Windows XP SP2 and Windows Server 2003 SP1. You can also download BITS 2.0 for Windows Server 2003, Windows XP SP1, Windows XP, Windows 2000 SP4, and Windows 2000 SP3. To download BITS 2.0, go to the Microsoft Download Center and install KB 842773.
  • The version of %windir%\System32\QMgr.dll is 6.6.xxxx.xxxx.
Version 1.5
  • Added upload and upload-reply capability, command-line execution for events, explicit credentials, and support for Windows 2000.
  • Included in Windows Server 2003. A redistributable is available for Windows XP and Windows 2000 SP3 from the Microsoft Download Center.
  • The version of %windir%\System32\QMgr.dll is 6.5.xxxx.xxxx.
Version 1.2
  • Same functionality as version 1.0. Contains internal upgrades and improvements.
  • Included in Windows XP SP1 and Windows 2000 SP3.
  • The version of %windir%\System32\QMgr.dll is 6.2.xxxx.xxxx.
Version 1.0
  • Initial release. Provides prioritized, throttled, and asynchronous downloads in the background or foreground. The downloads automatically resume after computer restarts and network disconnects.
  • Included in Windows XP.
  • The version of %windir%\System32\QMgr.dll is 6.0.xxxx.xxxx.
Bitsadmin is versioned based on the BITS version. Figure 2 shows the version of BITS and the source for the corresponding version of Bitsadmin.

Version Bitsadmin Source
Version 2.0 Windows Server 2003 Service Pack 1 32-bit Support Tools
Windows XP Service Pack 2 Support Tools go.microsoft.com/fwlink/?LinkId=68007
Version 1.5 Windows Server 2003 Support Tools
Windows Server 2003 CD, Support\Tools folder
Version 1.2 Windows XP Service Pack 1 Support Tools
Windows XP Service Pack 1 CD, Support\Tools folder
Version 1.0 Windows XP RTM Support Tools
Windows XP RTM CD, Support\Tools folder
If you’re going to use BITS and scripting for your downloading tasks, it’s a good idea to have at least BITS 2.0 installed. BITS 1.5 and later allow an action to be executed after the transfer is complete. BITS 2.0 allows transfers from SMB server shares as well as HTTP transfers, so the source file(s) for a BITS job can be on a file server. BITS 2.0 also includes a new BITS policy setting called Maximum Network Bandwidth, which you access in the Computer Configuration\Administrative Templates\Network\Background Intelligent Transfer Service node of the Group Policy Object Editor. If you have Windows XP Service Pack 2 (SP2), Windows Server 2003 SP1, or later, you have at least BITS 2.0. It is also available as a download for older service packs.

Bitsadmin Commands
Now let’s look at a series of Bitsadmin commands used to create a BITS job, as shown in Figure 3. The example assumes that the client computer is running Windows XP or Windows Server 2003 with BITS 1.5 or higher, and that bitsadmin.exe is located in the %SystemRoot%\system32 folder (generally C:\Windows\system32 by default on a new Windows XP installation).
bitsadmin /create myDownloadJob
bitsadmin /addfile myDownloadJob http://www.contoso.com/downloads/test.exe 
	C:\Downloads\Test.exe
bitsadmin /SetNotifyCmdLine myDownloadJob "%SystemRoot%\system32\bitsadmin.exe" 
	"%SystemRoot%\system32\bitsadmin.exe /complete myDownloadJob "
bitsadmin /resume myDownloadJob
 
The Create command creates the BITS job in a suspended state. You add files to the job with the AddFile command. The SetNotifyCmdLine switch lets you define a command to launch when the transfer is finished. In this case it runs the Bitsadmin command to Complete the BITS jobs. (A job must be completed after the transfer is finished.) The Resume command starts the download.
For complete Bitsadmin command syntax, at a command prompt you should type: bitsadmin /?

Sample VBScript
I created a sample VBScript—BITSJob.vbs—to avoid having to create command shell scripts manually with Bitsadmin commands. You can use the script with Bitsadmin.exe to create BITS jobs that will download a URL file, a single UNC shared file, or an entire Universal Naming Convention (UNC) shared folder. (There is no scriptable COM interface to BITS for use in VBScript or other languages, so Bitsadmin is currently the only tool for scripting BITS.)
To use BITSJob.vbs, first make sure your computer has BITS 2.0 or higher. Next, you need bitsadmin.exe. If you are using Windows XP or Windows Server 2003, use the version from the Windows Server 2003 SP1 Support Tools. (The Windows XP SP2 Support Tools version has a known issue that does not allow it to be used correctly with the Windows Script Host WshShell.Exec method to capture StdOut.) Windows Vista already has bitsadmin.exe in the OS. Due to the quirky syntax of the Bitsadmin SetNotifyCmdLine command syntax, the location of bitsadmin.exe must not have any spaces in its path. So for this version of the script, the bitsadmin.exe location is hardcoded to %SystemRoot%\system32. You must copy it there on Windows XP or Windows Server 2003. (It’s already in this location on Windows Vista.)
BITSJob.vbs works in two stages. You use it first to create a CMD file, then the CMD file is used to actually execute the bitsadmin commands. The remote file or folder needs to be available when you run the script or CMD file. The advantage of this is that you can look at the total file count in a remote folder (shown in the CMD file) to see if there are too many files for BITS to handle in one job. Due to limitations of BITS, it is not recommended for jobs with more than 100 files. You can comment out any files you decide not to add to the job. (An optional switch for BITSJobs.vbs lets you execute the CMD file immediately after it is created.) Use bitsadmin’s /list or /info switches to check on the status of your BITS jobs.
BITSJobs.vbs is available at Code Downloads. I’ve included a small CMD file along with the download that shows examples of the BITSJobs.vbs switches. You can also get help by executing
cscript BITSJobs.vbs /?
at a command prompt.

Michael Murgolo is a Senior Infrastructure Consultant for Microsoft Consulting Services. He is focused in the areas of operating systems, deployment, network services, active directory, systems management, automation, and patch management. He is a subject-matter expert in the area of desktop deployment and migration.
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker