Posts about Windows

Windows Installer Problem at Work

November 28th, 2008

I logged into a new domain at work today and experienced a few problems, it may be just coincidence but it caused me a headache.

I first realised that I couldn’t start Outlook 2003, the installer started, as it does when you start a new profile, and then just quit with a not-very-useful error message. To check if it was a general problem I used Add/Remove Programs to try another program, sure enough the Windows Installer was broken with this error.

The Windows Installer Service could not be accessed. This can occur if you are running Windows in safe mode, or the Windows Installer is not correctly installed. Contact your support personnel for assistance.

Fortunately searching for this returns a Microsoft Support Article and number one on the list fixed the problem for me, to quote.

Method 1: Unregister and re-register the Windows Installer

1. Click Start, click Run, type MSIEXEC /UNREGISTER, and then click OK. Even if you do this correctly, it may look like nothing occurs.
2. Click Start, click Run, type MSIEXEC /REGSERVER, and then click OK. Even if you do this correctly, it may look like nothing occurs, or you may briefly see an hourglass. After you run this command, the operation is complete.
3. Try your Windows Installer-based application again.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Display Server Time Using Javascript and ASP.NET in C#

November 20th, 2008

I’ve recently written an ASP.NET page using C# that required displaying the server time on the webpage using Javascript. To do this you need to output the Javascript code using C# and initialise the Javascript Date() object with the server time, after playing around I found this code does the job.

"server_time = new Date('" + DateTime.Now.ToString("MMMM d, yyyy HH:mm:ss") + "');"

The entire code looks like this assuming you have a label with id=’clock’ on the page. Just output the string js to the page to add the clock.

const string crlf = "\r\n";
string js = "<script type='text/javascript'>" + crlf +
"window.onload=startclock;" + crlf +
"var clock;" + crlf +
"var time_diff;" + crlf +
"function startclock(){" + crlf +
   "clock=document.getElementById('clock');" + crlf +
   "server_time = new Date('" + DateTime.Now.ToString("MMMM d, yyyy HH:mm:ss") + "');" + crlf +
   "time_diff=new Date()-server_time;" + crlf +
   "setInterval('runclock()',1000);" + crlf +
"}" + crlf +
"function runclock(){" + crlf +
   "var cDate=new Date();" + crlf +
   "cDate.setTime(cDate.getTime()-time_diff);" + crlf +
   "var curr_hours = cDate.getHours();" + crlf +
   "var curr_mins = cDate.getMinutes();" + crlf +
   "var curr_secs = cDate.getSeconds();" + crlf +
   "curr_hours=(curr_hours < 10)?'0' + curr_hours:curr_hours;" + crlf +
   "curr_mins=(curr_mins < 10)?'0' + curr_mins:curr_mins;" + crlf +
   "curr_secs=(curr_secs < 10)?'0' + curr_secs:curr_secs;" + crlf +
   "clock.innerHTML=curr_hours+':'+curr_mins+':'+curr_secs;" + crlf +
   "}" + crlf +
"</script>";

I should mention that if you’re using classic ASP and VBScript then the line becomes.

"server_time = new Date(" & DatePart("yyyy",Date) & "," & DatePart("m",Date)-1 & "," & DatePart("d",Date) & "," & DatePart("h",Now) & "," & DatePart("n",Now) & "," & DatePart("s",Now) & ");"
Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Remove DOS newlines from Python files

September 17th, 2008

I’ve been working on a few python files in WIndows and then moving them to Linux but whenever I try to run them I get an error about ‘directory not found’.

I soon discovered that the Windows carriage return messes up the files for Linux so we need to remove them all. If you open the offending file using vi you’ll see lots of ^M characters spread through the file. Fortunately these are pretty easy to remove using vi. Open the file in vi, press escape so we can enter a command, type this command press enter and save the file.

%s/^M/ /g

It’s very important that you create the ^M character by typing alt+v then press m while still holding down alt+v, do not paste straight from this page.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Windows Scheduled Tasks Problem

September 5th, 2008

On my work PC I have some batch jobs set up that run from a network resource. Because of this I have to set up the job with my domain user name and password.

This worked fine until I changed my network password yesterday, suddenly I was getting ‘Access Denied’ messages when I tried to save the jobs.

After a long talk with IT it turns out that my new password was the problem, I was trying to use ‘iosteam::in’ as my password but it seems that the double colon is not accepted or recognised by Windows Scheduled tasks so if you get the same problem just change your password and all should be OK.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

No More New Fonts May Be Applied In This Workbook

July 31st, 2008

I came across this very strange error message in Microsoft Excel today. The user has a workbook with 114 charts and he seemed to be hitting some hard limit in Excel.

It turns out that if you create a chart with it’s font set to ‘Auto scale’ then instead of using one font it uses 2 or more and there is a limit of 512 fonts per workbook. The fix is easy, there’s even a script to loop through all the chart objects and change the setting for you.

For the solution see the page on the Microsoft Help and Support.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Notepad Plus One

June 24th, 2008

On Linux I usually use vi as my text editor or, for html work, Bluefish, but on windows these are not available.

While writing a program to import text files into a database I was using notepad to view the files to see how to best import them. At this point I became very frustrated that notepad doesn’t even support line and column counters so I can see where I am in a document (useful when parsing fixed width files).

After a short search I’ve downloaded Notepad++, it’s powerful, fast and best of all GPL licensed! I recommend you ditch notepad and try this instead.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Windows 64 Bit or 32 Bit

May 6th, 2008

Being one of those people that ‘knows’ about computers I often get asked if I can recommend computers to people.

I always find this very difficult for quite a few reasons.

  • If they give me a budget do they actually want to spend up to the budget or do they really want the cheapest possible under the budget. I can always recommend very cheap computers but would they rather spend more and get one that is slightly more ‘future proof’.
  • Understanding their priorities is very difficult. Would they rather have more RAM or is a wireless keyboard and mouse more important. If they want wireless, do they want 802.11g or are they moving large files over a network and are prepared to pay for 802.11n? They say they play games but are we talking hardcore gamer or the odd game of Solitaire?

It’s often made worse by the fact they they probably don’t fully understand what they want either, it’s just that I’m always a bit nervous recommending something that they might not approve of after they’ve bought it. In reality I know that this is very unlikely since they are far less critical than I am.

One interesting problem I have right concerns Windows 64 versions. A friend is looking to buy a gaming pc probably with and Intel E8400 processor. Having looked at the website of the company they might buy it from it’s clear that they recommend Windows 64 Bit especially since the default set-up of the computer has a whopping 8GB or RAM!. My problems are:

  • With Vista 64 Bit many of his old games will not run at all since they will not be compatible with Vista, plus Vista 64 Bit requires signed drivers so many of his current peripherals just won’t work and new drivers don’t exist (nor will they ever)
  • Vista 32 Bit still has compatibility problems plus only supports 4GB of RAM (see here and here for more information).
  • In Denmark Windows XP 64 Bit is only available in the Professional Edition localised to the UK, it must be a Danish edition so that won’t work.
  • Windows XP Home 32 Bit will work with his current games but only support 4GB of RAM. This is not a major problem but it seems like I’m going for the lowest common denominator.

Overall the situation is very confusing. I would really like to jump on the 64 Bit bandwagon since it’s they way of the future but until you can be sure all your hardware will work happily together.

I don’t want to obsolete all his games and current hardware by upgrading to Vista 64 Bit so I have no choice but to recommend a 7 year old operating system that will be officially discontinued as of June 30, 2008, not an ideal situation.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Spell Checking in Microsoft Word

April 30th, 2008

My girlfriends computer has Windows Vista installed in Danish but has the UK version of Office 2003 Professional so I was rather surprised this week that I couldn’t change the spell check language in Word 2003 to Danish.

I had (rather naively as it turns out) just assumed that something costing as much as Office 2003 would also include a pile of dictionaries for spell checking, how wrong could I be.

To achieve what I wanted I’d actually have to buy Microsoft Office Proofing Tools 2003, which seems hard right now as all the sites I looked at showed it as discontinued!

To put this in context I use OpenOffice on Linux (cost zero) and installing a new dictionary takes me about 1 minutes using yum (cost also zero).

On a similar theme I was recently helping a friend with her computer when she asked me if she should buy Microsoft Word for her pc just so she can read Word attachments that are sent to her. She had very basic requirements and was not at all computer literate.

It struck me that for most people if they are sent a Word document they will of course assume they need Word to view the file, Microsoft Office document formats are so ubiquitous that many people just connect any text file with Word.

The idea that people fork out for Microsoft Word just for this purpose horrifies me when there are many free alternatives available. But of course knowledge is power in my case, many people are not so lucky.

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Vista SP1 Not Resolved Network Problems

April 18th, 2008

I installed Vista SP1 on my girlfriends computer yesterday (it’s in Danish which wasn’t one of the original release languages, hence the delay) and was disappointed to find that her computers network problem has not been fixed.

After writing about Microsofts problems with selling Vista to businesses it was funny to read this article where Steve Ballmer describes Vista as a ‘work in progress’.

As the article says, every piece of software is actually a work in progress, we all expect new verisons and enhansments to be released, but for such a figure to say this while at the same time trying to convince corporations to embrace Vista it sounds like for a moment he forgot his marketing spiel and the truth slipped out

Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Using ADO With JavaScript

April 6th, 2008

When writing HTAs to connect to an MS Access database I used to always use VBScript.
The obvious reason for this being that it seemed easier since both are Microsoft technologies plus I initially had no idea how to create or use ActiveXObjects from JavaScript.

After doing this for a while I became very frustrated at the limitations of using VBScript so looked deeper into changing to JavaScript and found that’s it’s actually very easy to use.

As a starter for anyone else in the same position here some framework code showing how to create an ADO connection, open a recordset and execute the command object all using JavaScript.
(I know technically this is JScript, which is Microsofts version of JavaScript)

// path to database
var DBpath="\\\\Server\\Path\\myDB.mdb"

// set up a few object constants
var adLockReadOnly=1
var adOpenForwardOnly=0
var adCmdText=1

// create and open a new connection (MSAccess)
var cnn=new ActiveXObject("ADODB.connection")
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=" + DBpath
try
    {
    cnn.open
    }
catch(err)
    {
    // could not open connection
    // view details in err.Description and err.Number
    return 0
    }

//open a read only recordset
var rs = new ActiveXObject("ADODB.Recordset")
try
	{
	rs.Open("Select * from myTable", cnn, adOpenForwardOnly, adLockReadOnly)
	}
catch(err)
	{
	// could not open recordset
	return 0
	}
while(!rs.EOF)
	{
	// do something
	rs.movenext
	}
rs.close

//insert records with command object
var cmd=new ActiveXObject("ADODB.command")
cmd.ActiveConnection = cnn
cmd.CommandText = "Insert into myTables values(x ,y ,z)"
cmd.CommandType=adCmdText
    try
    {
    cmd.Execute()
    }
    catch(err)
    {
    // could not execute SQL
    return 0
    }
Google BookmarksEvernoteGoogle GmailHotmailWordPressLinkedInFacebookDeliciousShare

Switch to our mobile site