WMIC – command-line control of WMI functions

Before Windows PowerShell and all the flexibility (and complexity) that brings, there was WMIC, the command-line client for WMI.

WMIC works out of the box with Windows XP and later (including Server 2003 and Vista), and allows access to operations provided via WMI: “a powerful, user-friendly interface to the WMI namespace”. Upon first use, the WMIC environment is installed:

C:\> WMIC

Please wait while WMIC is being installed...

Several tasks which normally feel very GUI-oriented, such as checking the battery status, are made very “command-line” with WMIC:

C:\> WMIC Path Win32_Battery Get BatteryStatus /Format:List

BatteryStatus=1

In this case, the batter is discharging. You can see the beginnings of PowerShell in the syntax and detailed status/operations available. Another useful command is useraccount, to return details of the user accounts on the system:

C:\> WMIC useraccount list brief
AccountType  Caption                  Domain     FullName       Name   SID
512          SKELTON-M\Administrator  SKELTON-M  Administrator         S-1-5-21-68**03330-*********-839**2115-500
512          SKELTON-M\Guest          SKELTON-M  Guest                 S-1-5-21-68**03330-*********-839**2115-501
...

Or how about terminating a specific process (notepad.exe) from the command-line? Here we go:

C:\> WMIC process where name='notepad.exe' call terminate

Executing (\\SKELTON-M\ROOT\CIMV2:Win32_Process.Handle="4652")->terminate()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

It’s helpful to install the WMI Administative Tools, so you can explore the WMI namespace and investgate the operations available to you via WMIC. For example, to determine the name of the time zone currently used by the system, use the TimeZone path:

C:\> WMIC Path Win32_TimeZone Get StandardName /Format:List

StandardName=GMT Standard Time

The time zone for my computer currently is “GMT Standard Time”.

For simple operations which do not merit PowerShell scripts or installation, WMIC is a good choice.

Improving broadband speed with BT

If you are not one of the lucky ones to have received a recent cost-free upgrade from BT to 20MBit/s ADSL, and your broadband speed is less than good, here are some steps to diagnose the problems.

First we’ll check the actual line speed.

Go to http://bthomehub/ or maybe http://bthomehub.home/ – note: no “www” or “com” in there. If you get a status page then you are looking at the modem/router (BT Home Hub). It should give some stats like these:

My broadband connection
Your broadband line is connected.
Broadband connection details:
Downstream 15,323 Kbps
Upstream 888 Kbps
Connection time 3 days, 22:58:21
Data transmitted 166.57 MB
Data received 3.21 GB

It’s the Upstream an Downstream values which you need to record somewhere. The values should be at least 2,000 Kbps Downstream (“2 Meg”) and at least 200Kbps Downstream for a basic broadband service (these speeds will soon be mandatory).

If your speeds are less than or close to these values, you can try some of these steps:

1. Get a BT Broadband Accelerator – basically a better microfilter.

http://www.productsandservices.bt.com/ consumerProducts/displayTopic.do? topicId=25075&s_cid=btb_FURL_accelerator

Go here, and select “Yes” in response to “Do you have more than one working phone socket in your home?” Then choose the socket which matches your “master socket” – hopefully it’s like #4. Sockets #1-#3 do not work with the Accelerator. Then you pay the P&P and BT deliver it – no other charges.

Installation should be simple. Do this first (or else establish that your socket is incompatible), and then (if the speed does not increase) try option 2 below.

2. Run the BT speed test wizard: http://bt.custhelp.com/cgi-bin/bt.cfg/php/enduser/cci/bt_adp.php? p_sid=&cat_lvl1=346&cat_lvl2=401&cat_lvl3=407&cat_lvl4=753 &p_cv=4.753&p_cats=346,401,407,753&p_faqid=12666 or here: https://bt.custhelp.com/cgi-bin/bt.cfg/ php/enduser/doc_serve.php?&5=7. This asks you some questions about your connection.

This page also contains some good advice, which you can check, particularly around faulty wiring:
http://bt.custhelp.com/cgi-bin/bt.cfg/ php/enduser/cci/bt_adp.php? p_sid=bgLqHKKj&p_faqid=9611&cat_lvl1=346 &cat_lvl2=401&cat_lvl3=407& p_cv=3.407&p_cats=346,401,407

e.g.

Check for faulty home internal phone wiring

Poorly-installed home phone wiring or poor quality phone extension leads (often with a flat rather then round cable profile) are the most common causes of slow broadband speeds. This is because they are more prone to electrical interference, which causes BT Broadband to reduce data speeds to compensate. You can test for this as follows:

  1. If you have a phone master socket like the one in the photo here (that is, square with a horizontal groove halfway down it, and removable upper and lower cover), we recommend you remove the lower cover as shown, taking care not to dislodge any wiring. Do not remove the upper cover. This will reveal a test socket on the right-hand side. This connects directly to the exchange, bypassing your home phone wiring and extensions.Phone master socket
  2. Plug your router or modem directly into this test socket via a microfilter.
  3. Recheck your connection speed as per Step 2 above, ensuring you refresh your browser page first. If your connection speed has increased significantly, this indicates a likely fault or interference source within your home wiring. If it remains unchanged, this indicates either no fault, or the fault or interference is more likely to be in BT’s wiring or in your local exchange.

Re-run the line speed checks (at http://bthomehub/) and check the new Upstream and Downstream speeds. Are they significantly different?

3. Finally, if the above do not fix the issue, BT have a “Broadband Accellerator” service where an engineer comes to the house:

http://bt.custhelp.com/cgi-bin/bt.cfg/ php/enduser/cci/bt_catpage.php? cat_lvl1=346&cat_lvl2=1282& cat_lvl3%20=1859&p_cv=3.1859&p_cats=346,1282,1859

The work we do on your home wiring should increase your connection speed by at least 1Mbps” – if your current connection is only 2Mbps, this would represent a 50% speed increase.

If your Internet connection speed (independent of the broadband network speed) has not increased by at least 0.5Mbps, you are entitled to claim your money back.

It’s not clear how much this service costs, but I think it’s about £80.

Your final option is… move to the city!

Send Large Files (UK Version)

With FTP a bit old-skool (and insecure), and all the firewall problems with FTPS and its variants, online web-based file sharing tools have sprung up over the last few years.

Of these, box.net and yousendit.com are the best known, but suffer a common limitation of many of these services, with small upload sizes (unless you pay), and are based in the US, so upload and download times are increased.

Pando advert

The best UK-based site for sharing large files seems to be DropSend (yes, all the good names have gone), which offers up to 2GB uploads for free, an – crucially for me in terms of respectability – displays its UK registered company number on the home page, unlike some other sites like Pando which seem more like spam factories, with inappropriate adverts (see screenshot).

Merge tracking with Subversion 1.6

I am now running Subversion 1.6 for my client’s SVN repositories. I upgraded mainly to take advantage of the Merge tracking introduced in Subversion 1.5, and improved in 1.6. In particular, Subversion now creates its own “mergeinfo” entries, so you no longer have to use the svnmerge.py script. Subversion 1.6 now has better detection of “tree conflicts” – essentially, problems with the local working copy caused by renames, missing files, etc.

I used the new release of VisualSVN Server to install and upgrade SVN in a painless way (see earlier post on VisualSVN Server). The new version installs over the top of the previous one, so back up your SVN repositories first.

An important part of the Subversion philosophy is “don’t break things”. Even though VisualSVN Server 2.0 runs Subversion 1.6, the underlying repository format is not upgraded automatically, meaning that the new merge tracking feature is still not (yet) available. To get this working we simply need to run “svnadmin upgrade PATH”, like this:

> svnadmin upgrade D:\Data\Svn\DevDoctor
Repository lock acquired.
Please wait; upgrading the repository may take some time...

Upgrade completed.

Following a working copy svn update, you can run svn merge. In this case, I used TortoiseSVN:

Here, we were merging from the development branch, so I selected Reintegrate a branch. Once the correct settings have been chosen, you can even “Test merge”, which gives you a report of what would happen if you went ahead with the merge. When the changes are successfully merged, Tortoise shows the results:

As normal, the merge needs to be committed, but the crucial difference after the commit succeeds is that Subversion itself has tracked the merge using the mergeinfo property:

You can see that an svn:mergeinfo property has been set on the folder, showing the branch from which the merges were done, and the revision numbers (here, 400-409).

All this means that merging (both from branches to trunk, and from trunk to branches) is all much less tricky and error-prone than before (with Subversion 1.4). Subversion 1.6 is also noticeably quicker than 1.4 for all operations so far.

Further reading: http://scm.jadeferret.com/subversion-16-new-features-explained/

PayPal "cart upload" – much smoother than "Add to cart"

We have just finished some custom PayPal integration for Eaton Square Concerts (ESC). On the ESC booking page, you can now select all the tickets you want before heading to PayPal, thanks to the PayPal “cart upload” feature. Previously, the site was using the single-item “Add to cart” which is a bit clunky, and means the user heads back and forth between the ESC site and PayPal.

We handle the form submission on the ESC site, work out what the user want to buy, read their response to the optional questions, and then send the form off to PayPal. The intermediate step is needed because PayPal refuses to accept a zero-count for items, forcing us to check the item count before POSTing to PayPal.