Home » 2016 » August » 3 » BITSadmin : download/upload files from windows command line.

1:03 PM
BITSadmin : download/upload files from windows command line.

BITSADMIN version 3.0 [ 7.8.10586 ]
BITS (Background Intelligent Transfer Service
) administration utility.
(C) Copyright 2000-2006 Microsoft Corp.

BITSAdmin is a command line tool available in windows starting from windows xp till current versions. 

It is used to create download or upload jobs and monitor their progress.

It is deprecated and is not guaranteed to be available in future versions of Windows.


Administrative tools for the BITS service are now provided by BITS PowerShell cmdlets.



FORMAT

BITSADMIN [/RAWRETURN] [/WRAP | /NOWRAP] command
where commands can be any of the following:

/TRANSFER <job name> [type] [/PRIORITY priority] [/ACLFLAGS flags] remote_url local_name

    Transfers one of more files.
    [type] : may be /DOWNLOAD or /UPLOAD; default is download
    Multiple URL/file pairs may be specified.
    Unlike most commands, <job name> may only be a name and not a GUID.

We shall try below example to understand it:

bitsadmin /transfer "job" http://pc001.update.www.cmcm.com/file/install/cleanmaster_12_1.exe D:\here.exe

Note:- Please provide the local path name in double quotes to avoid errors as some file/folder names are having spaces.


Once the job is added for downloading/uploading, you can control them  using below commands.

/LISTFILES <job>                     Lists the files in the job


/SUSPEND <job>                       Suspends the job


/RESUME <job>                        Resumes the job

It removes the job from the transfer queue and deletes all temporary files associated with the job.


/CANCEL <job>                        Cancels the job


/COMPLETE <job>                      Completes the job

/GETTYPE <job>                       Retrieves the job type


/GETACLFLAGS <job>                   Retrieves the ACL propagation flags


Once the job is downloaded, you can see following status;

 

DISPLAY: 'job' TYPE: DOWNLOAD STATE: TRANSFERRED
PRIORITY: NORMAL FILES: 1 / 1 BYTES: 5767600 / 5767600 (100%)
Transfer complete.


 

Similarly we have several other features of this tools which are listed below:

/CREATE [type] <job name>               Creates a job
    [type] may be /DOWNLOAD, /UPLOAD, or /UPLOAD-REPLY; default is download
    Unlike most commands, <job name> may only be a name and not a GUID.

/INFO <job> [/VERBOSE]                   Displays information about the job


/ADDFILE <job> <remote_url> <local_name> Adds a file to the job

Adds a file to the specified job. RemoteURL is the URL of the file on the server. LocalName is the name of the file on the local computer. LocalName must contain an absolute path to the file.


/ADDFILESET <job> <textfile>             Adds multiple files to the job
   Each line of <textfile> lists a file's remote name and local name, separated by spaces.  A line  beginning with '#' is treated as a comment.
   Once the file set is read into memory, the contents are added to the job.

 

/ADDFILEWITHRANGES  <job> <remote_url> <local_name range_list>
   Like /ADDFILE, but BITS will read only selected byte ranges of the URL.
   range_list is a comma-delimited series of offset and length pairs.
   For example,

       0:100,2000:100,5000:eof

   instructs BITS to read 100 bytes starting at offset zero, 100 bytes starting
   at offset 2000, and the remainder of the URL starting at offset 5000.

/REPLACEREMOTEPREFIX <job> <old_prefix> <new_prefix>
    All files whose URL begins with <old_prefix> are changed to use <new_prefix>

Note that BITS currently supports HTTP/HTTPS downloads and uploads.
It also supports UNC paths and file:// paths as URLS

 

/SETACLFLAGS <job> <ACL_flags>       Sets the ACL propagation flags for the job
  O - OWNER       G - GROUP
  D - DACL        S - SACL

  Examples:
      bitsadmin /setaclflags MyJob OGDS
      bitsadmin /setaclflags MyJob OGD


Following are the options to retrieve info about a queued job:

/GETBYTESTOTAL <job>                 Retrieves the size of the job
/GETBYTESTRANSFERRED <job>           Retrieves the number of bytes transferred
/GETFILESTOTAL <job>                 Retrieves the number of files in the job
/GETFILESTRANSFERRED <job>           Retrieves the number of files transferred
/GETCREATIONTIME <job>               Retrieves the job creation time
/GETMODIFICATIONTIME <job>           Retrieves the job modification time
/GETCOMPLETIONTIME <job>             Retrieves the job completion time
/GETSTATE <job>                      Retrieves the job state
/GETERROR <job>                      Retrieves detailed error information
/GETOWNER <job>                      Retrieves the job owner
/GETDISPLAYNAME <job>                Retrieves the job display name
/SETDISPLAYNAME <job> <display_name> Sets the job display name
/GETDESCRIPTION <job>                Retrieves the job description
/SETDESCRIPTION <job> <description>  Sets the job description
/GETPRIORITY    <job>                Retrieves the job priority
/SETPRIORITY    <job> <priority>     Sets the job priority



Priority usage choices:
      FOREGROUND
      HIGH
      NORMAL
      LOW


/GETNOTIFYFLAGS <job>                 Retrieves the notify flags
/SETNOTIFYFLAGS <job> <notify_flags>  Sets the notify flags
    For more help on this option, please refer to the MSDN help page for SetNotifyFlags/GETNOTIFYINTERFACE <job>             Determines if notify interface is registered
/GETMINRETRYDELAY <job>               Retrieves the retry delay in seconds
/SETMINRETRYDELAY <job> <retry_delay> Sets the retry delay in seconds
/GETNOPROGRESSTIMEOUT <job>           Retrieves the no progress timeout in seconds
/SETNOPROGRESSTIMEOUT <job> <timeout> Sets the no progress timeout in seconds
/GETMAXDOWNLOADTIME <job>             Retrieves the download timeout in seconds
/SETMAXDOWNLOADTIME <job> <timeout>   Sets the download timeout in seconds
/GETERRORCOUNT <job>                  Retrieves an error count for the job

/SETPROXYSETTINGS <job> <usage>      Sets the proxy usage
   usage choices:
    PRECONFIG   - Use the owner's default Internet settings.
    AUTODETECT  - Force autodetection of proxy.
    NO_PROXY    - Do not use a proxy server.
    OVERRIDE    - Use an explicit proxy list and bypass list.
                  Must be followed by a proxy list and a proxy bypass list.
                  NULL or "" may be used for an empty proxy bypass list.
  Examples:
      bitsadmin /setproxysettings MyJob PRECONFIG
      bitsadmin /setproxysettings MyJob AUTODETECT
      bitsadmin /setproxysettings MyJob NO_PROXY
      bitsadmin /setproxysettings MyJob OVERRIDE proxy1:80 "<local>"
      bitsadmin /setproxysettings MyJob OVERRIDE proxy1,proxy2,proxy3 NULL

/GETPROXYUSAGE <job>                 Retrieves the proxy usage setting
/GETPROXYLIST <job>                  Retrieves the proxy list
/GETPROXYBYPASSLIST <job>            Retrieves the proxy bypass list

/TAKEOWNERSHIP <job>                 Take ownership of the job


 

/SETNOTIFYCMDLINE <job> <program_name> [program_parameters]
    Sets a program to execute for notification, and optionally parameters.
    The program name and parameters can be NULL.
    IMPORTANT: if parameters are non-NULL, then the program name should be the
               first parameter.

  Examples:
    bitsadmin /SetNotifyCmdLine MyJob c:\winnt\system32\notepad.exe  NULL
    bitsadmin /SetNotifyCmdLine MyJob c:\callback.exe "c:\callback.exe parm1 parm2"
    bitsadmin /SetNotifyCmdLine MyJob NULL NULL

/GETNOTIFYCMDLINE <job>              Returns the job's notification command line

/SETCREDENTIALS <job> <target> <scheme> <username> <password>
  Adds credentials to a job.
  <target> may be either SERVER or PROXY
  <scheme> may be BASIC, DIGEST, NTLM, NEGOTIATE, or PASSPORT.

/REMOVECREDENTIALS <job> <target> <scheme>
  Removes credentials from a job.
/GETCUSTOMHEADERS <job>                           Gets the Custom HTTP Headers
/SETCUSTOMHEADERS <job> <header1> <header2> <...> Sets the Custom HTTP Headers
/GETCLIENTCERTIFICATE <job>                       Gets the job's Client Certificate Information
/SETCLIENTCERTIFICATEBYID <job> <store_location> <store_name> <hexa-decimal_cert_id>
  Sets a client authentication certificate to a job.
  <store_location> may be
        1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE),
        4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY),
        7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE).

/SETCLIENTCERTIFICATEBYNAME <job> <store_location> <store_name> <subject_name>
  Sets a client authentication certificate to a job.
  <store_location> may be
        1(CURRENT_USER), 2(LOCAL_MACHINE), 3(CURRENT_SERVICE),
        4(SERVICES), 5(USERS), 6(CURRENT_USER_GROUP_POLICY),
        7(LOCAL_MACHINE_GROUP_POLICY) or 8(LOCAL_MACHINE_ENTERPRISE).

/REMOVECLIENTCERTIFICATE <job>                

Removes the Client Certificate Information from the job

/SETSECURITYFLAGS <job> <value>
   Sets the HTTP security flags for URL redirection and checks performed on the server certificate during the transfer.
   The value is an unsigned integer with the following interpretation for the bits in the binary representation.
     Enable CRL Check                                 : Set the least significant bit
     Ignore invalid common name in server certificate : Set the 2nd bit from right
     Ignore invalid date in  server certificate       : Set the 3rd bit from right
     Ignore invalid certificate authority in server
       certificate                                    : Set the 4th bit from right
     Ignore invalid usage of certificate              : Set the 5th bit from right
     Redirection policy                               : Controlled by the 9th-11th bits from right
         0,0,0  - Redirects will be automatically allowed.
         0,0,1  - Remote name in the IBackgroundCopyFile interface will be updated if a redirect occurs.
         0,1,0  - BITS will fail the job if a redirect occurs.

     Allow redirection from HTTPS to HTTP             : Set the 12th bit from right

/GETSECURITYFLAGS <job>
   Reports the HTTP security flags for URL redirection and checks performed on the server certificate during the transfer.

/SETVALIDATIONSTATE  <job>  <file-index> <true|false>
      <file-index> starts from 0
    Sets the content-validation state of the given file within the job.

/GETVALIDATIONSTATE  <job>  <file-index>
      <file-index> starts from 0
    Reports the content-validation state of the given file within the job.

/GETTEMPORARYNAME  <job>  <file-index>
      <file-index> starts from 0
    Reports the temporary filename of the given file within the job.

The following options control peercaching of a particular job:

/SETPEERCACHINGFLAGS  <job> <value>
    Sets the flags for the job's peercaching behavior.
    The value is an unsigned integer with the following interpretation for the bits in the binary representation.
        Allow the job's data to be downloaded from a peer : Set the least significant bit
        Allow the job's data to be served to peers        : Set the 2nd bit from right

/GETPEERCACHINGFLAGS  <job>
    Reports the flags for the job's peercaching behavior.

The following options are valid for UPLOAD-REPLY jobs only:

/GETREPLYFILENAME <job>        Gets the path of the file containing the server reply
/SETREPLYFILENAME <job> <path> Sets the path of the file containing the server reply
/GETREPLYPROGRESS <job>        Gets the size and progress of the server reply
/GETREPLYDATA     <job>        Dumps the server's reply data in hex format

 

 
 

Category: Technical Solution | Views: 2227 | Added by: shanky | Tags: download a file using command line, Bits, bitsadmin, upload download a file | Rating: 5.0/1

Related blogs


You may also like to see:


[2014-02-08][Technical Solution]
File sharing between Host computer and virtual machine
[2015-12-30][Technical Solution]
SOLVED : Big problem of windows 10, internet speed reduces greatly. Turn off Windows update.
[2014-09-30][Technical Solution]
How to give a global url to an HTML page? How to create a website with custom url?
[2015-03-28][Technical Solution]
Control your Samsung mobile remotely : lock, track, wipe data when lost
[2014-02-11][Technical Solution]
Advanced Encryption Standard (AES) algorithm : an algorithm for encryption and decryption for secure data transfer

Total comments: 0
avatar