Archive

Archive for the ‘Windows tips’ Category

Running Windows 8 with wide screen display in VirtualBox

August 31st, 2012 No comments

If you have tried running Windows 8 in Virtual Box (a great way to try out a new Windows version before taking the leap to install it as your main OS) you might have noticed that the only display resolutions available are in 4:3 aspect ratio.

To fix this, open a command prompt (PowerShell in my case) do this:

C:\Program Files\Oracle\VirtualBox> .\VBoxManage.exe setextradata “Windows 8 test” CustomVideoMode1 1600x900x24

“Windows 8 test” is the name of the virtual machine in VirtualBox and you can select any resolution you want. Restart the virtual machine if it’s running and after that the new resolution will be available in the Screen Resolution settings inside Windows 8.

Note that it’s possible to add several new resolutions to choose from by using CustomVideoMode1, CustomVideoMode2, etc. This can be useful if you want to move between monitors in multi-monitor setups. To do that in full-screen mode, press <Host>-Home which will show a popup menu where the display can be configured. <Host> is mapped to Right-Ctrl by default.

Credits for this tip:
Running Windows 8 on VirtualBox with Additional Wide Screen Resolution

/Emil

Categories: Windows tips Tags: ,

Retrieving the message count for MSMQ queues

December 11th, 2011 3 comments

Sometimes it can be useful to retrieve the number of messages in an MSMQ queue, for example for monitoring. However, it’s not immediately apparent how to do it if you google it, so here are my thoughts on the subject.

Other blog posts suggest iterating over messages (e.g. Counting Messages in an MSMQ MessageQueue from C#) or doing it using WMI. WMI is the best alternative in my opinion and if you want a quick way of doing it then PowerShell is the easiest:

$queues = Get-WmiObject Win32_PerfFormattedData_msmq_MSMQQueue
$queues | ft -property Name,MessagesInQueue

The result will be something similar to this:

Name                                                         MessagesInQueue
----                                                         ---------------
active714\private$\notify_queue$                                           0
active714\private$\deltagarloggservice\deltagarloggservi...                0
active714\private$\order_queue$                                            0
active714\private$\admin_queue$                                            0
Computer Queues                                                           27

This can also be done on remote machines:

$host = ...
$cred = get-credential
$queues = Get-WmiObject Win32_PerfFormattedData_msmq_MSMQQueue -computer $host -credential $cred
$queues | ft -property Name,MessagesInQueue

The Get-Credential Cmdlet will display a login dialog which is fine in interactive sessions but if you need to set the credentials in a non-interactive script, then the tip in this blog post might help: PowerShell – How to create a PSCredential object.

Retrieving message counts from code takes a little more coding but here’s an example in C# that searches for a given queue and returns its message count:

private static int GetMsmqMessageCount(string queuePath, string machine,
  string username, string password)
{
  var options = new ConnectionOptions
    {Username = username, Password = password};
  var path = string.Format(@"\\{0}\root\CIMv2", machine);
  var scope = new ManagementScope(path, options);
  scope.Connect();

  string queryString = 
    String.Format("SELECT * FROM Win32_PerfFormattedData_msmq_MSMQQueue WHERE Name = '{0}'",
	  queuePath);
  var query = new ObjectQuery(queryString);

  var searcher = new ManagementObjectSearcher(scope, query);

  IEnumerable<int> messageCountEnumerable = 
    from ManagementObject queue in searcher.Get()
    select (int) (UInt64) queue.GetPropertyValue("MessagesInQueue");

  return messageCountEnumerable.First();
}

This code also uses WMI but this time we do a query rather than enumerate all queues.

The above snippets has worked well for us so I felt it would be useful to post them here. Please leave a comment if you have issues with them or suggestions for improvement!

/Emil

Zune Desktop Theme for Windows XP

February 4th, 2009 1 comment

Tired of your old Windows XP theme? Can’t decide which color scheme is the least ugly (blue, olive green or silver)?

Then why not try the Zune Desktop Theme for Windows XP? It’s designed to resemble the look of the Zune player, so I suppose its purpose is to inspire an interest in that device. Still, it looks quite good if you ask me:

zunetheme_crop

If you’re interested, download the theme here:

http://go.microsoft.com/fwlink/?LinkID=75078

Categories: Windows tips Tags:

Windows hibernation problems – solved!

November 27th, 2008 No comments

Do you use the hibernation feature of Windows? Ever had any problems with it? I suspect that the answers to these two questions generally are the same…

Firstly, if you’re using Windows XP and have more than 2 GB of RAM, it doesn’t work. Fortunately there’s a fix. For more info, see here.

Secondly, you’re likely to have run into a host of other problems. My experiences include:

  • Hibernation works, but the computer is immediately awakened
  • Instead of hibernating, the computer is turned off
  • Instead of hibernating, I’m logged out to the welcome screen

All these are extremely irritating, of course. Fortunately I’ve found a solution to all my problems so far, namely a little known but excellent free tool called MCE Standby tool (MST) that helps you configure the hibernation options. If you have similar problems to mine, give it a go!

When you install the tool, it puts a small, green “power” icon in the system tray:

To configure the hibernation options, right-click the system tray icon, and the main window is displayed:

To fix my two last problems above, I changed Selected sleep state to “S3″, restarted the computer (might be unnecessary) and then changed back to “S4″. Voilá, problems gone.

If you have problems with the computer awakening immediately after hibernation then it might be a USB-connected device that’s waking the computer up (a mouse, keyboard, remote control receiver, etc). To fix this, you can select which deviced should be allowed to wake the computer up and this is done in the Devices tab:

Deselect all devices you suspect to be causing problems, and no awakening should occur. For me it was my keyboard.

There are more options in the useful little tool, but these are the ones that helped me so far. Give it a try if you have similar problems!

/Emil

BTW, “MCE” in the tools name stands for “Media Center Edition” indicating that hibernation problems can often be related to media systems. And indeed, many of my problems started after I installed Media Portal. My advice concerning that system is of course to keep away from it…

Categories: Windows tips Tags:

XP Automatic Update Nagging

June 2nd, 2006 No comments

Yes, it is possible to disable the Automatic Updates, Restart Now/Later dialog box! Look here.

Categories: Windows tips Tags:

Server Error: Failed to access IIS metabase.

April 20th, 2006 No comments

I have received this error several times when trying to run an ASP.NET 2.0 application on a fresh machine:

Server Error in '/Butler/EducationSI' Application.
--------------------------------------------------------------------

Failed to access IIS metabase.


Failed to access IIS metabase.jpg

The error normally goes away when reinstalling the .Net Framework 2.0 (it might be sufficient to repair the installation in “Add or Remove Programs” in the Control Panel).

Categories: .Net programming, Windows tips Tags:

List web applications in IIS and their ASP.NET versions

February 17th, 2006 No comments
C:\>aspnet_regiis.exe  -lk
W3SVC/  1.1.4322.0
W3SVC/1/ROOT/Butler/UtbildareSI/        2.0.50727.42
W3SVC/1/ROOT/Butler/SecuritySI/ 2.0.50727.42
W3SVC/1/ROOT/Butler/Public.SecuritySI/  2.0.50727.42
W3SVC/1/ROOT/Butler/PersonregisterSI/   2.0.50727.42
W3SVC/1/ROOT/Butler/CommonEntity/       2.0.50727.42
W3SVC/1/ROOT/Reports$SQL2005/   2.0.50727.42
W3SVC/1/ROOT/ReportServer$SQL2005/      2.0.50727.42

C:\>
Categories: Windows tips Tags:

Switch to our mobile site

Web Analytics