January 2005 - Posts

BITS stands for Background Intelligent Transfer Service and is designed to perform downloads of large files in the background and to support download resuming. It's intelligent because it can suspend automatically when the network connection is needed for other (foreground) tasks and will automatically resume when the needed resources become available. And, it also can maintain file transfers through network disconnections and computer restarts. In fact everyone knows BITS indirectly, since it's being used by the Windows Update service (you probably know the balloon in the system tray that tells you when an update becomes available and when it has been downloaded). Now, the great news is that you can actually use BITS yourself to perform large downloads (or if you want to take it even further, you can employ BITS in your own applications to perform download jobs). I'll focus in this post on the manual process of getting BITS to work for your own tasks.

  1. To kick off you need to grab the bitsadmin.exe tool from the support tools available on the cd-rom (in my case Windows Server 2003, I assume it's available on the Windows XP cd-rom too). In fact, you just install the Support Tools MSI (suptools.msi) which will add a program group to the start menu. Over there, open up a Support Tools Command Prompt.
  2. The second thing to do is to create a job:

    C:\Program Files\Support Tools>bitsadmin /create myjob
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Created job {26082B7C-FAC5-4489-BE6C-298E2E1078CD}.
  3. Okay, we have a job right now. Check this by executing bitsadmin /list:

    C:\Program Files\Support Tools>bitsadmin /list
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    {26082B7C-FAC5-4489-BE6C-298E2E1078CD} myjob SUSPENDED 0 / 0 0 / 0
    Listed 1 job(s).


    This indicated that the job is actually empty and does not contain a file to download.
  4. Now it's time to add a file to the job, as follows:

    C:\Program Files\Support Tools>bitsadmin /addfile myjob http://someserver/vdir/file.dat c:\temp\file.dat
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Added http://someserver/vdir/file.dat -> c:\temp\file.dat to job.
  5. Let's add a notification first that will warn us when the download has completed:

    C:\Program Files\Support Tools>bitsadmin /setnotifycmdline myjob c:\windows\system32\net.exe "send %COMPUTERNAME% Download completed"
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    notification command line set to 'c:\windows\system32\net.exe' 'send PAPAGENO Download completed'.

    Note that you'll need the Messenger service on your pc to execute this demo; it would be better to use another mechanism to show the message since the Messenger service is disabled by default (for security reasons) and it's not recommended to turn it on. However, for the purpose of this demo, I'll assume that the Messenger service on your system is enabled.
  6. When you query the job again, you'll see it's suspended:

    C:\Program Files\Support Tools>bitsadmin /list
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    {26082B7C-FAC5-4489-BE6C-298E2E1078CD} myjob SUSPENDED 0 / 1 0 / UNKNOWN
    Listed 1 job(s).

  7. To start it, we need to resume the job:

    C:\Program Files\Support Tools>bitsadmin /resume myjob
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Job resumed.
  8. In the system tray, you should see network activity on your network adapter (if the icon of the adapter is visible of course):

    C:\Program Files\Support Tools>bitsadmin /list
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    {26082B7C-FAC5-4489-BE6C-298E2E1078CD} myjob TRANSFERRING 0 / 1 10418497 / 35565576
    Listed 1 job(s).


    The progress of the download can be queried at all times through the bitsadmin tool.
  9. If you want to suspend the job you can use the /suspend parameter, like this:

    C:\Program Files\Support Tools>bitsadmin /suspend myjob
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Job suspended.

    Don't execute this right now. However, when the download is taking place, the interactive users on the system should not see side effects of this when working with the network. That is, the file transfer will the throttled to limit the used bandwidth. You can actually test this by consuming other network resources (e.g. perform a couple of downloads on the internet using a browser) and monitoring the BITS download state using bitsadmin /list. You can also play with system restarts and disconnections of the network cable.
  10. While the download is taking place, take a look at the target folder. You'll see a file BITA1.tmp (or a similar name, note that it's a hidden file) that contains the download (so far). You'll see that the file is growing while the download is busy. After a while, you'll see the notification popping up, indicating that the download has finished. Query the jobs again:

    C:\Program Files\Support Tools>bitsadmin /list
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    {26082B7C-FAC5-4489-BE6C-298E2E1078CD} myjob TRANSFERRED 1 / 1 35565576 / 35565576
    Listed 1 job(s).

    As you can see, the file has been transferred (one file out of a total of one files + size indications).
  11. Although the transfer has completed, the temporary file is still in the target folder. In order to get the file you need to complete the job:

    C:\Program Files\Support Tools>bitsadmin /complete myjob
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Job completed.

    Which makes the file available in the target folder.
    The associated job will be deleted as well:

    C:\Program Files\Support Tools>bitsadmin /list
    BITSADMIN version 1.5 [ 5.2.3790.0 ]
    BITS administration utility.
    (C) Copyright 2000-2002 Microsoft Corp.
    Listed 0 job(s).

I'm using this technology quite often right now and have a little C# tool for it (nothing special, just a Windows Forms tool that calls the bitsadmin.exe tool through the System.Diagnostics.Process class, and that allows to display a notification in the system tray when a download has finished).

Update: You can also get a .NET managed code wrapper for BITS on MSDN via this link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwxp/html/WinXP_BITS.asp. If I find the time to complete my download manager implementation using BITS, I'll post the solution over here (up till now, I'm using the command-line tools to start a download job).

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Recently, I've received a bunch of spam on my blog. Luckily I'm maintaining the database of my blog myself, so I can make any changes I want in order to get rid of all this nonsense information. I found a really nice way to do this is by using triggers as explained on http://netnerds.net/articles/285.aspx. Using a separate table called "bannedwords" you can ban certain words in feedback posts (determined by @PostType = 3), like poker, mortgage and other well-known spam words.Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Yesterday, my 7200 RPM harddisk (Hitachi TravelStar 60 GB) arrived for my laptop. A welcome relief. Performance is far better than with the old harddisk, and it was the ideal occasion for me to have a reinstall of my OS. Beside of that, by moving from 40 GB to 60 GB I can finally have two partitions on my system again (and I still have another harddisk for demos). The problem (if it should be called a problem after all) is that for a 'standard installation' I require over 30 GB (Windows Server 2003 OS, Visual Studio 6, Visual Studio .NET 2003, Office tools, SQL Server 2000, some betas including Visual Studio 2005 and SQL Server 2005, Express Tools, etc etc). The secondary partition is likely to become a Windows XP Professional or Windows Longhorn installation.

A tip when you're running Windows Server 2003 on a laptop is to disable the Indexing service to save harddisk load. On Windows XP it seems that this service is disabled by default, whileas (after adding the appropriate server roles) on Windows Server 2003 it is enabled. As I posted before, SP1 RC1 for Windows Server 2003 is a great innovation as well (I can finally use WPA on my laptop to connect to my WLAN). Unfortunately, BlueTooth support is still not present (as far as I'm aware of) which would be the only reason for my to have Windows XP on the system as well (demos with PocketPC development).

A couple of days ago I started playing with the Windows XP Embedded platform builder etc and Windows CE 5.0 development (only experiments right now) to create a stripped-down OS for Windows Media, internet gateways and thin client support. If you want to start playing around with these technologies I recommend to check out Mike Hall's demos on http://msdn.microsoft.com/embedded/getstart/basics/default.aspx. To get the software, browse to http://www.windowsembeddedkit.com where you can grab the latest versions of the Windows Embedded technologies.

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Yet another part of the Trustworthy Computing initiative at Microsoft. This tool will be updates regularly (every second Tuesday of the month) and it will come through Windows Update and Automatic Updates as well in order to check your computer for well-known worms. Direct link: http://www.microsoft.com/downloads/details.aspx?FamilyID=ad724ae0-e72d-4f54-9ab3-75b8eb148356&DisplayLang=en. For the on-line version go to http://www.microsoft.com/security/malwareremove/default.mspx. Enjoy, hopefully the scan detects nothing on your system... :-)

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Although this InfoPath template is available for a long time already via http://weblogs.asp.net/guowu/archive/2004/07/20/187990.aspx, I didn't try it yet. Since I'm moving some things around on my web server to improve security, I decided to look at some new ways to edit my website(s) more effectively and to reorganize things. Posting through InfoPath is likely to become one of those improvements.
 
By the way, as from yesterday on, I moved my mail to Hostbasket Exchange 2003 hosting (www.hostbasket.com). I've been running this for a while at my former secondary school in Zottegem (www.deinsbeke.be) where we host Exchange 2003 mailboxes for about 500 students and teachers but since these machines are behind an ADSL line, it's rather slow to have access to OWA etc, although one big advantage was that - as an admin - I could set up a mailbox of unlimited size (when is RDPed in to the network yesterday I came to the conclusion that my mailbox had grown over 1GB already). By the way, the network that we built over there is pretty cool in terms of used Microsoft software, 4 times Windows Server 2003 (with AD, WSS, IIS 6, etc), ISA Server 2004, Exchange 2003 and a SQL Server 2000.
 
If you can read this post, the blogging experiment through InfoPath works perfectly well.
Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

As some of you may know, I'm a kind of mouse-hater. When I can do something without a mouse, I'll do it. Start Internet Explorer is for me as easy as Win+R, iexplore, Enter. Task Manager via Ctrl-Shift-Esc, close windows with Alt-F4, switch between windows using Alt-Tab. You name it, I'll always try to avoid the use of the mouse. In my opinion, you can work faster without mouse than with a mouse (okay, I'm not doing graphics or so, for which a pointing device is great). However, in Virtual PC I had the problem (till some minutes ago) that once a Virtual PC window has focus, you can't 'escape' from the VPC windows with the guest OS. What I mean is that Alt-Tab is sent to the guest OS running in that window, so you can't "Alt-Tab out that window" to switch to another window on the host OS. So I always needed to grab the mouse to do this kind of thing (click on another window on the host OS' taskbar). Got it?

Now, here comes the trick: <host key>+<Arrow down> allows you to minimize the VPC guest OS window and then switch to another window on the host OS using Alt-Tab. This is cool! Virtual PC, you made my day...

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Yesterday I had a problem with RIS (remote installation services), something that's categorized as "by design". The problem is this: when you create an image using riprep.exe it takes an image of your harddisk (of course it does) but it also stores characteristics of your partition on the server (e.g. partition of 40 GB). When you try to 'download' the image (using PXE-boot) to another smaller harddisk (which has enough capacity to hold the complete image however, e.g. 4GB used of the 40 GB) it won't work (nice little error message, see http://support.microsoft.com/default.aspx?scid=kb;en-us;320982 for the official description and solution). Yeah great :-)

So, I came to the conclusion that RIS has to store somewhere on the server the size of the partition that was used to make the image (what a deductive brain, wow). The file in question is Imirror.dat (in the i386\Mirror1 directory). It's a binary file, but using a tool like WinHex you can clearly see that it holds the partition data (as well as the used HAL, OS version, directory for the OS installation, file system type, drive letter). Luckily we had another Imirror.dat file that was created by running riprep.exe on a computer with a smaller harddisk size. In fact only 15 bytes in the two files were different. If I find some time, I'll try to find out where the partition size is kept, but for now replacing the file of the image that was too big by the other one (created by riprep on the computer with the smaller harddisk size) worked like a charm.

For people who don't have an image of a smaller harddisk yet, the following procedure can help:

  1. Use the computer with the smallest harddisk that needs to be RIS-ed.
  2. If it already has an OS on it, start riprep.exe (via the UNC path \\server\reminst\); otherwise install an OS first (just the core is enough) and start riprep.exe.
  3. While running riprep.exe on the computer with the smaller harddisk, watch the Images folder on the server, in particular the Mirror1 directory of the new image; the Imirror.dat file is made very early in the riprep.exe process (before the files of the harddisk are copied to the server).
  4. Grab that Imirror.dat file and copy it to the Mirror1 folder of the image to-be-fixed (but make sure you keep the original file by renaming it).

Hopefully this information is helpful for other people struggling with this as well. Please note that this is not a supported solution (refer to KB article).

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Microsoft recently acquired the software from Giant, a company specialized in things like anti-spyware. The beta of the software is on-line now on http://download.microsoft.com/download/8/1/5/815d2d60-49b5-44dc-ae35-fca2f2c6f0cc/MicrosoftAntiSpywareInstall.exe. Enjoy it.Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Definitely worth to check out: http://blogs.msdn.com/jhoward/archive/2005/01/04/346147.aspx. Although I'm primarily focusing on development, Virtual Server is one of these things I've been concentrating on quite heavily the past year since I was co-responsible for the ATE booth of Virtual Server 2005 on both TechEd Europe (A'dam) and IT Forum (Copenhagen).Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

More Posts