Posts about Windows

Wireless Network Scanner

March 30th, 2010

I recently came across a free, open source wireless network scanner. It available from the MetaGeek website and is called inSSIDer.

It’s very simple to use, just select the wireless adapter and start scanning. The graph displays all the wireless networks with their signal strengths and shows both 2.4GHz and 5GHz bands.

I ran the scan from my flat and found 52 access points, but fortunately mine was the only one running on the 5GHz band :-)

Insert TimeStamp Into Access Using C#.NET and C++.NET

November 11th, 2009

There’s a rather strange difference between using C#.NET and C++.NET when using a parameter query to insert a TimeStamp into an MS Access database (field type Date/Time).

The following C# code works perfectly.

OleDbCommand cmd = new OleDbCommand();
cmd.Parameters.Add("@login_timestamp", OleDbType.DBTimeStamp).Value = DateTime.Now.ToString();
cmd.CommandText = "insert into myTable values (?)";

However when converting the same code to C++ you cannot just use OleDbType::DBTimeStamp as this results in an error when inserting the data, instead you have to use OleDbType::Date so the code looks like this.

OleDbCommand ^cmd;
cmd=gcnew OleDbCommand();
cmd->Parameters->Add("@login_timestamp", OleDbType::Date)->Value = DateTime::Now;
cmd->CommandText = "insert into myTable values (?)";

C# Replace New Lines

October 29th, 2009

If you know you’re working on the Windows platform and all data will come from Windows then to replace newlines using C#.NET we just use.

myString=myString.Replace(Environment.NewLine,"");

In all other cases it’s much safer to string together the Replace function to cover all possibilities.

myString=myString.Replace("\r", "").Replace("\n", "");

C# IsNumeric

October 28th, 2009

If you do a search for ‘C# IsNumeric’ you’ll find a lot of hits talking about why this function is available in VB.NET but not in C#.NET. It’s used to test if a given string can be converted to a number.

I agree it’s a very useful function and there’s lots of possible solutions, the main ones being

  1. Loop through the string and check each Char is a number
  2. Use Double.TryParse is a very popular one since it doesn’t throw an exception on failure
  3. Use Convert.ToInt32 inside a try/catch block
  4. Using a Regex expression

I really wanted to use Double.TryParse but unfortunately this will return true for numbers that are decimals. Therefore if you want to test a string for whole numbers you also have to check the string for periods or commas (using string.contains) depending on your locale.

For this reason I tend to use the Regex solution, mainly because it’s very short and simple to implement.

public static bool IsNumeric(string str)
       {
            return Regex.IsMatch(str, "^[0-9]+$");
       }

It also requires the using directive System.Text.RegularExpressions

I am Microsoft Support

May 26th, 2009

Like many people who are interested in IT one of my secondary functions is to help friends and family ‘fix’ their computers. Of course I’m happy to do this but sometimes problems just make me want to tear my hair out (I’m of course talking about Windows Vista here).

This time it was trying to fix a Toshiba Satellite U300 laptop running Vista Home Premium. The computer booted and reached the login screen but we couldn’t login. Every time a warning appeared saying something about the ‘SNES service could not log you in as the security token could not be found’.

I Googled for a solution and tried to fix it using sfc /scannow and a few other commands but nothing worked so rather than waste more time I decided to reinstall since there was no valuable data to loose.

The initial reinstall went fine (if very slowly) but soon after it all started to go wrong. Since the laptop is a couple of years old there were of course plenty of updates from Microsoft, I expected it to initially find Vista SP 1 but instead Windows Update found 73 other updates. I decided that it must know best (sometimes other updates are required before you can install a SP after all) but I was wrong.

About 2 hours and 3 reboots later the updates were installed but then the computer would not shutdown, it would just hang at the ‘Logging off’ screen and only a hard reset would turn it off. During the updates I knew a few system restore points must be created so I decided to roll back a few updates to see if I could pinpoint where it sent wrong. Unfortunately system restore stubbornly refused to fulfil it’s sole purpose, stopping with an error that ‘System restore could not complete the restore’ or something equally cryptic and useless.

There was nothing to do except for another reinstall. Except this time I downloaded the Vista SP1 Standalone file so I could force SP1 as the first update. Sure enough this worked fine, so the next time I rebooted I only had 3 updates from Windows Update to install.

With that out of the way I only had to remove the 10-15 bloatware applications installed by Toshiba (desktop sidebar gadgets for eBay and Amazon, DesktopSMS software etc etc…) and the laptop was as good as new!

The main points to come out of this are.

  1. When Windows goes wrong it really goes wrong. Often it’s just not worth trying to fix the problem, rather just reinstall.
  2. Windows Update needs to be a lot smarter.
  3. Why the hell is Windows Update so slow. Download, install, reboot while updating, install some more…it just goes on and on. Can it really take 2 hours and 3 reboots to install 73 updates?
  4. Microsoft Windows is a commercial product that often points to lack of Linux support as a major failing of Linux. But realistically how many people actually call Microsoft to fix their computer when their OS fails. I’m guessing the outside the US it’s not many, it’s left to friends and family to run MS support for free.
  5. Why does Vista in particular make me feel like I’ve lost control of my computer. Everything seems so well hidden that when it works it’s OK but when it fails you’re on your own.

For sure the learning curve for Linux is steeper but it just does many things right.

  1. Having not used my Fedora 10 system for a while it needed 131 updates the last time I booted it. Even on an old laptop this took about 40 minutes to complete with no reboots at all. When I did reboot, the system was just as stable as before.
  2. Sure I’ve had a few problems but because everything is open and easy to find I can nearly always trace the problem and fix it myself. I’ve NEVER reinstalled the OS to fix a problem.
  3. I have control of my computer, no clicking through license agreements whenever I update a program and no entering of license keys to check that I’m allowed to use the software.

I still enjoy the challenge of fixing other peoples computers but I’m wondering if I should charging Microsoft for my time!

Following Microsoft vs Tom Tom

March 6th, 2009

I’ve been reading plenty about the Microsoft case against Tom Tom recently. Essentially Microsoft is suing Tom Tom over claims that their in car GPS systems infringe on some of Microsofts patents.

As a couple of sites have pointed out it seems that Tom Tom is being forced into a corner whereby they either pay up to Microsoft and in the process open themselves up to being sued for infringement of the GPL license or drop Linux and be forced to use Microsoft embedded systems in future.

Either way it’s a loose-loose situation for Tom Tom, even if standing up to Microsoft instead of paying up and signing their Non-disclosure agreement is the right thing to do.

It does seems that with Linux on netbooks, smartphones (and maybe netbooks) using Google Android and thePalm Pre Microsoft is feeling the pressure.

Of course many have pointed out that if Microsoft enforces patents on the FAT file system one of the consequences may be that device manufacturers will move over to a GPL licensed system like ext2 instead. Oh the irony!

Start IIS from the Command Line

January 28th, 2009

This is more of a note to myself as I keep forgetting, but to start IIS (5.1 in my case) you just need type the following into a terminal.

net start w3svc

Windows 7 Beta Impressions

January 14th, 2009

Even though I’m a Linux enthusiast I still thought I’d have a look at the new Windows 7 Beta that was released to the public on Saturday.

I should also say that I’m very pleased that Microsoft decided to lift the 2.5 million limit on the number of license keys available but can’t help but think the whole situation was planned. It was obvious that after saying the only 2.5 million keys will be available there would be a huge rush that would cripple the site and get huge publicity.

Apart from the initial server overload it went very well downloading the beta, I got both the 32 and 64 bit files downloaded in about 30 minutes so they must have got something right in the end.

I installed the 32 Bit version into Virtualbox, no need to screw up a ‘real’ computer these days. The procedure is very simple but installing the guest Additions needs a slight tweak, the clearest instructions I’ve found are on the Sun Blogs site.

On installing there was a long delay between the ‘Windows is extracting files..’ message and the next stage, I actually thought it had silently crashed but just be patient as it does work in the end.

As for my impressions, yes it’s slick, looks very nice and runs extremely well in my virtual machine, but coming from a Linux point of view it’s boring. I’m sure the masses will love it but I just feel that with each advancement it puts me one step further away from knowing what my computer is doing.

I also wonder why the 32 Bit iso is 2.6GB (and the 64 Bit is 3.15GB) when there’s virtually no software included (although paint has the ribbon interface, woo hoo!). The Fedora 10 iso is 3.5GB but includes GIMP, OpenOffice, MySQL, Apache, Perl and thousands of other packages out of the box. Why Windows should be so large is a total mystery to me.

I also wonder about the small things, Windows 7 Beta still seems to have the same notepad that’s been around since Windows 1.0. Search Google and you find thousands of hits for notepad replacements (I use Notepad++) and yet Microsoft didn’t bother upgrading the one shipping with their flagship product, strange.

DVD Burning in Windows XP

December 22nd, 2008

I don’t often burn CDs or DVDs, and even then it’s usually to burn a Linux ISO file to disk so I can use it to boot another PC.

Yesterday I put a blank DVD into my Windows XP laptop and dragged the ISO file onto the disc folder only to be presented with some nasty error. After very little research I soon discovered that Windows XP doesn’t support DVD burning out of the box. I must admit I was shocked.

Quoting from this Microsoft page from 2002:

Windows XP doesn’t contain built-in support for burning DVDs

The next time someone complains that Linux doesn’t play mp3s or their favourite video codec is not included I’ll just point out this fact to them. Linux is free so this is somewhat forgiveable, but the Last time I checked Windows XP Professional SP3 is not free and I expect a hell of a lot better.

I eventually downloaded CDBurner XP which works very well.

Toggle Windows Proxy Settings

December 19th, 2008

If you use a laptop both at home and at work it gets really annoying having to switch between using and not using a proxy server to connect to the internet.

Having found quite a few sites explaining how to get the ProxyEnable registry value it’s pretty trivial to make a VBScript that toggles the flag on and off. Just save this script in a file with a .vbs extension and double click to run. Each time it runs it will just toggle the proxy on and off .

I could write the usual warning about modifying the registry but we’re all adults here….

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"
objRegistry.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
if dwValue=0 then
	dwValue=1
else
	dwValue=0
end if
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue
if dwValue=1 then
	msg="Proxy Enabled"
else
	msg="Proxy Disabled"
end if
msgbox msg,64,"Proxy Toggle"