BITSADMIN - CMD


Overview

BITSADMIN is a command-line tool that allows management of Background Intelligent Transfer Service (BITS), a service in Windows that facilitates asynchronous, prioritized, and throttled transfer of files between machines using idle network bandwidth. This tool is primarily used for transferring large data files without degrading network performance and is often utilized in application updates, download managers, and network administration scripts.

Syntax

The basic syntax for BITSADMIN is:

bitsadmin /operation [parameters]

Where /operation specifies the action to be performed (like create, addfile, resume, etc.) and [parameters] are the options specific to the operation.

bitsadmin /create /download job_name 
bitsadmin /addfile job_name remote_url local_path
bitsadmin /resume job_name
bitsadmin /complete job_name
bitsadmin /cancel job_name

Options/Flags

Each operation in BITSADMIN has its specific flags. A few commonly used options include:

  • /create: Creates a new transfer job. Requires a job type (/download, /upload, or /upload-reply) and a job name.
  • /addfile: Adds a file to a transfer job. Requires the job name, the remote URL, and the local path where the file is to be saved or uploaded from.
  • /resume: Resumes a paused transfer job.
  • /pause: Pauses an active transfer job.
  • /cancel: Cancels the specified transfer job.
  • /list: Lists all current BITS jobs or the specifics of the given job.
  • /info: Displays details for the specified job.
  • /complete: Completes the file transfer and releases all associated resources.

Examples

Creating and Managing a Download Job:

  1. Create a download job:
    bitsadmin /create /download myDownloadJob
    
  2. Add a file to the job:
    bitsadmin /addfile myDownloadJob https://example.com/file.zip C:\downloads\file.zip
    
  3. Resume the job:
    bitsadmin /resume myDownloadJob
    
  4. Once completed, finalize the job:
    bitsadmin /complete myDownloadJob
    

Common Issues

  • Permission Errors: Ensure you have appropriate permissions to access or modify the files and directories involved.
  • Network Issues: BITS jobs may fail or pause automatically due to network connectivity issues. Ensure stable network access.
  • Job Limitations: There’s a limit to how many BITS jobs can be active at once, which might cause issues in creating new jobs.

Integration

BITSADMIN can be effectively coupled with batch scripts or PowerShell to automate downloading or uploading tasks. Here is an example of using a batch script to manage BITS jobs:

@echo off
bitsadmin /create /download myJob
bitsadmin /addfile myJob https://example.com/largefile.zip C:\Temp\largefile.zip
bitsadmin /resume myJob

:wait
bitsadmin /info myJob | findstr "STATE" | find "TRANSFERRED"
if %errorlevel% neq 0 (
    timeout /t 5
    goto wait
)

bitsadmin /complete myJob
echo Download completed.
  • PowerShell BITS Cmdlets: Modern alternative to BITSADMIN, offers more control and is recommended for new scripts.
  • Robocopy: For robust file copying with retry logic, often used in place of BITS for LAN environments.

Additional resources and documentation can be found on the Microsoft official website. For advanced usage, consider moving to PowerShell BITS cmdlets as BITSADMIN is deprecated in newer versions of Windows.