DonChunior Posted August 4, 2021 Share Posted August 4, 2021 (edited) Introduction In the course of my research for a project involving, among other things, the transfer of large amounts of data, I came across the BITS service and from that the idea for this UDF was born. For a brief overview, I'll quote from Microsoft's BITS website (https://docs.microsoft.com/en-us/windows/win32/bits/background-intelligent-transfer-service-portal). Quote Purpose Background Intelligent Transfer Service (BITS) is used by programmers and system administrators to download files from or upload files to HTTP web servers and SMB file shares. BITS will take the cost of the transfer into consideration, as well as the network usage so that the user's foreground work has as little impact as possible. BITS also handles network interuptions, pausing and automatically resuming transfers, even after a reboot. BITS includes PowerShell cmdlets for creating and managing transfers as well as the BitsAdmin command-line utility. Where applicable Use BITS for applications that need to: Download from or upload files to an HTTP or REST web server or SMB file server. Automatically resume file transfers after network disconnects and computer restarts. Preserve the responsiveness of other network applications. Be mindful of the network cost on e.g. roaming networks Optionally work with BranchCache to optimize wide area network (WAN) traffic Availability 🛒 The BITS UDF can be downloaded from my GitHub repository: 🔗 https://github.com/DonChunior/BITS-UDF Comments 💬 Currently, only an alpha version of the UDF is available. This contains by and large the full functionality of the object interfaces, but still completely lacks error checking and handling. I will implement this in the upcoming beta version. Therefore I ask you to use the UDF only for testing purposes but not in productive code! Acknowledgment 🤝 Many thanks to @Nine and @Danyfirex. You helped me very well in solving some tricky problems. Edited August 5, 2021 by DonChunior Formatting improvement. Danyfirex, Nine, Earthshine and 1 other 2 2 Link to comment Share on other sites More sharing options...
Nine Posted August 5, 2021 Share Posted August 5, 2021 I would highly suggest that you create an example framework to show how to properly use your UDF to download one and/or multiple files. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
DonChunior Posted August 5, 2021 Author Share Posted August 5, 2021 1 hour ago, Nine said: I would highly suggest that you create an example framework to show how to properly use your UDF to download one and/or multiple files. You're right about that, of course, and I promised that in the roadmap section of the README file on GitHub. Examples will make it much easier to get started using BITS. Link to comment Share on other sites More sharing options...
Nine Posted August 5, 2021 Share Posted August 5, 2021 (edited) _BITS_Connect does not work for me on Windows 7, it is hanging the script. So here what is working (error handling should obviously be added) : Func _BITS_Connect($iVersion = Default) Local $asBackgroundCopyManager_CLSIDs[] = [ _ "{5FD42AD5-C04E-4D36-ADC7-E08FF15737AD}", _ ; BITS 10.3 "{4575438F-A6C8-4976-B0FE-2F26B80D959E}", _ ; BITS 10.2 "{4BD3E4E1-7BD4-4A2B-9964-496400DE5193}", _ ; BITS 10.1 "{4D233817-B456-4E75-83D2-B17DEC544D12}", _ ; BITS 10.0 "{1ECCA34C-E88A-44E3-8D6A-8921BDE9E452}", _ ; BITS 5.0 "{BB6DF56B-CACE-11DC-9992-0019B93A3A84}", _ ; BITS 4.0 "{659CDEA7-489E-11D9-A9CD-000D56965251}", _ ; BITS 3.0 "{03CA98D6-FF5D-49B8-ABC6-03DD84127020}", _ ; BITS 2.5 "{6D18AD12-BDE3-4393-B311-099C346E6DF9}", _ ; BITS 2.0 "{F087771F-D74F-4C1A-BB8A-E16ACA9124EA}", _ ; BITS 1.5 "{4991D34B-80A1-4291-83B6-3328366B9097}" _ ; BITS 1.0 ] If $iVersion <> Default Then Return ObjCreateInterface($asBackgroundCopyManager_CLSIDs[$iVersion], $__BITSCONSTANT_sIID_IBackgroundCopyManager, $__BITSCONSTANT_sTagIBackgroundCopyManager) Local $oBackgroundCopyManager = 0 For $sBackgroundCopyManager_CLSID In $asBackgroundCopyManager_CLSIDs $oBackgroundCopyManager = ObjCreateInterface($sBackgroundCopyManager_CLSID, $__BITSCONSTANT_sIID_IBackgroundCopyManager, $__BITSCONSTANT_sTagIBackgroundCopyManager) If Not @error Then ExitLoop Next Return $oBackgroundCopyManager EndFunc ;==>_BITS_Connect I hardcoded it to 6 and it works well. Another solution would be to check @OSVersion and attempt to connect accordingly. Also please remove au3check directives, you should not force it. Edited August 5, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now