• 批处理命令下载网页


    BITSAdmin Examples

     

    The following examples show how to use the BITSAdmin tool to perform the most common tasks. For a complete list of switches and description of their use, see BITSAdmin Tool

    Transfer a File

    The /transfer switch is a shortcut for performing the tasks listed below. This switch creates the job, adds the files to the job, activates the job in the transfer queue, and completes the job. BITSAdmin continues to show progress information in the MS-DOS window until the transfer completes or an error occurs.

    bitsadmin /transfer myDownloadJob /download /priority normal http://downloadsrv/10mb.zip c:10mb.zip

    Create a Download Job

    Use the /create switch to create a download job named myDownloadJob.

    bitsadmin /create myDownloadJob

    BITSAdmin returns a GUID that uniquely identifies the job. Use the GUID or job name in subsequent calls. The following text is sample output.

    Created job {C775D194-090F-431F-B5FB-8334D00D1CB6}.
    

     

    Next, use the /addfile switch to add one or more files to the download job.

    Add Files to the Download Job

    Use the /addfile switch to add a file to the job. Repeat this call for each file you want to add. If multiple jobs use myDownloadJob as their name, you must replace myDownloadJob with the job's GUID to uniquely identify the job.

    bitsadmin /addfile myDownloadJob http://files.cnblogs.com/files/gayhub/bcn.js c:cn.bat
    

    o activate the job in the transfer queue, use the /resume switch.

    Sets the priority of the specified job.

    Syntax

    bitsadmin /SetPriority <Job> <Priority>
    

     

    Parameters

     

    ParameterDescription

    Job

    The job's display name or GUID

    Priority

    One of the following values:

    • FOREGROUND

    • HIGH

    • NORMAL

    • LOW

     he following example sets the priority for the job named myDownloadJob to normal.

    C:>bitsadmin /SetPriority myDownloadJob FOREGROUND
    

      

    Activate the Download Job

    When you create a new job, BITS suspends the job. To activate the job in the transfer queue, use the /resume switch. If multiple jobs use myDownloadJob as their name, you must replace myDownloadJob with the job's GUID to uniquely identify the job.

    bitsadmin /resume myDownloadJob
    

    o determine the progress of the job, use the /list/info, or /monitor switch.

    Determine the Progress of the Download Job

    Use the /info switch to determine the progress of a job. If multiple jobs use myDownloadJob as their name, you must replace myDownloadJob with the job's GUID to uniquely identify the job.

    bitsadmin /info myDownloadJob /verbose
    

     

    The /info switch returns the state of the job and the number of files and bytes transferred. When the state is TRANSFERRED, BITS has successfully transferred all files in the job. The /verbose argument provides complete details of the job. The following text is sample output.

     
     
    GUID: {482FCAF0-74BF-469B-8929-5CCD028C9499} DISPLAY: myDownloadJob
    TYPE: DOWNLOAD STATE: TRANSIENT_ERROR OWNER: domainuser
    PRIORITY: NORMAL FILES: 0 / 1 BYTES: 0 / UNKNOWN
    CREATION TIME: 12/17/2002 1:21:17 PM MODIFICATION TIME: 12/17/2002 1:21:30 PM
    COMPLETION TIME: UNKNOWN
    NOTIFY INTERFACE: UNREGISTERED NOTIFICATION FLAGS: 3
    RETRY DELAY: 600 NO PROGRESS TIMEOUT: 1209600 ERROR COUNT: 0
    PROXY USAGE: PRECONFIG PROXY LIST: NULL PROXY BYPASS LIST: NULL
    ERROR FILE:    http://downloadsrv/10mb.zip -> c:10mb.zip
    ERROR CODE:    0x80072ee7 - The server name or address could not be resolved
    ERROR CONTEXT: 0x00000005 - The error occurred while the remote file was being 
    processed.
    DESCRIPTION:
    JOB FILES:
            0 / UNKNOWN WORKING http://downloadsrv/10mb.zip -> c:10mb.zip
    NOTIFICATION COMMAND LINE: none
    

    To receive information for all jobs in the transfer queue, use the /list or /monitor switch.

    Need some delay times

    delay 4s

    ping -n 4 127.0.0.1>nul
    

      

    Completing the Download Job

    When the state of the job is TRANSFERRED, BITS has successfully transferred all files in the job. However, the files are not available until you use the/complete switch. If multiple jobs use myDownloadJob as their name, you must replace myDownloadJob with the job's GUID to uniquely identify the job.

    bitsadmin /complete myDownloadJob
    

    Monitoring Jobs in the Transfer Queue

    Use the /list/monitor, or /info switch to monitor jobs in the transfer queue. The /list switch provides information for all jobs in the queue.

    bitsadmin /list
    

    The /list switch returns the state of the job and the number of files and bytes transferred for all jobs in the transfer queue. The following text is sample output.

     
     
    {6AF46E48-41D3-453F-B7AF-A694BBC823F7} job1 SUSPENDED 0 / 0 0 / 0
    {482FCAF0-74BF-469B-8929-5CCD028C9499} job2 TRANSIENT_ERROR 0 / 1 0 / UNKNOWN
    
    Listed 2 job(s).
    

    Use the /monitor switch to monitor all jobs in the queue. The /monitor switch refreshes the data every 5 seconds. To stop the refresh, enter CTRL+C.

    bitsadmin /monitor
    

    The /monitor switch returns the state of the job and the number of files and bytes transferred for all jobs in the transfer queue. The following text is sample output.

     
     
    MONITORING BACKGROUND COPY MANAGER(5 second refresh)
    {6AF46E48-41D3-453F-B7AF-A694BBC823F7} job1 SUSPENDED 0 / 0 0 / 0
    {482FCAF0-74BF-469B-8929-5CCD028C9499} job2 TRANSIENT_ERROR 0 / 1 0 / UNKNOWN
    {0B138008-304B-4264-B021-FD04455588FF} job3 TRANSFERRED 1 / 1 100379370 / 100379370
    

    Deleting Jobs From the Transfer Queue

    Use the /reset switch to remove all jobs from the transfer queue.

    bitsadmin /reset
    

    The following text is sample output.

    {DC61A20C-44AB-4768-B175-8000D02545B9} canceled.
    {BB6E91F3-6EDA-4BB4-9E01-5C5CBB5411F8} canceled.
    2 out of 2 jobs canceled.

     参考文档:

    1.https://msdn.microsoft.com/en-us/library/aa362812(v=vs.85).aspx

    2.https://technet.microsoft.com/zh-cn/library/cc771868(v=ws.10).aspx

      

      

      

     

      

      

     

  • 相关阅读:
    Job for docker.service failed because the control process exited with error code. See
    连接数据库出现The server time zone value '�й���׼ʱ��' is unrecogni等问题的解决方案
    【面试】SSH 框架原理
    【面试】Spring 执行流程
    【面试】Redis
    Innosetup打包自动下载.net framework 动态库及替换卸载程序图标.
    分享一个带有合计行功能的DataGridView扩展
    记录一次系统优化
    使用 Cordova(PhoneGap)构建Android程序
    分享一个换肤解决方案
  • 原文地址:https://www.cnblogs.com/hester/p/7657540.html
Copyright © 2020-2023  润新知