Monday, July 25, 2011

Legacy Scripting Still King of User Empowerment

Attention has been shifting from legacy Windows scripting languages like VBScript to PowerShell. This is appropriate because PowerShell is, if you excuse the expression, more powerful.

However, there is one area where legacy scripting edges out PowerShell: user empowerment. What I mean by "user empowerment" is the ability for a user to unilaterally control their own computing environment.

For Windows XP and Vista, PowerShell has to be downloaded and installed. This requires Administrator privileges that some users won't have. PowerShell is bundled with Windows 7, but scripting is disabled by default and enabling it also requires Administrator privileges.

Now, in an ideal world, you'd contact your IT department and they'd promptly install PowerShell or enable it for you. In practice, however, there are usually institutional hurdles that make this a difficult and invasive process.

So if you find yourself on a locked-down Windows PC and you want to automate some of your work, consider VBScript or JScript.


Correction: on twitter informed me that you can enable PowerShell scripting without Administrator privileges for the current user. The command to use is: Set-ExecutionPolicy -Scope currentuser -ExecutionPolicy unrestricted

Saturday, April 23, 2011

5 Reasons Why a Republican Presidential Candidate Should Reject Birthism

I'm not a Republican, but I have some advice for Republican Presidential candidates. Make a public statement like this: "President Obama was born in the United States. It's a fact"

Of course, if you've already said the opposite or gave a wishy-washy answer, it's too late for you.

Here's five reasons making such a statement can help elect you:

1 It will separate you from the Pack

For the most part Republican Presidential candidates fall into two categories: Those who openly question Obama's birthplace and those who can't bring themselves to make a clear statement on the matter.

The moment you declare your belief that Obama was born in the US, you immediately become a big story no matter how obscure you were before. The fact that a famous publicity-hound like Trump is saying the opposite will keep you in the news for some time.

2 It will appeal to independent voters

Most independent voters will not vote for a candidate who is afraid to speak an obvious truth for fear of alienating a party or special interest group. You can convince them you are your own man (or woman).

3 It will let you deal with the Tea Party on your own terms

By signaling to the Tea Party that you aren't going to do whatever they want without question, you can court their support from a position of strength. As a Republican, you probably share at least some of the same policy views. The worst case scenario is that some of them might not vote, but there's no danger of them voting for Obama.

4 It will improve the reputation of your party

The Birther movement is making the Republican party look foolish. By rejecting it, you repair some of the damage.

5 It's the right thing to do

This might seem like odd political advice, but in a world of politics where half-truths, fallacious arguments, and deceptive language are the norm, doing the right thing can remind you that you had some good intentions going in. That can strengthen your resolve.

Monday, January 24, 2011

The Truth about the InternetExplorer Object and the WebBrowser Control

Recently I've been developing with VBScript. It's not because I think of it as a cutting-edge technology I need to learn, but rather because at work I'm stuck with a locked-down XP computer without any other programming tools, no internet access and no administrator privileges. Let's just say that software development isn't part of my current job description (There's a back-story here, but that's a story for a different day).

The application we are using at work is browser-based, but the UI (am I supposed to call it Ux now?) is horrible. Since our group is apparently far too low on the totem-pole to get our suggestions implemented, I've been writing scripts to ease our pain. The next step in this endeavor is to automate Internet Explorer and that's where the plot thickens.

There are two related "objects" you can use to automate IE: the InternetExplorer Object and the WebBrowser control. They are both available through Shdocvw.dll and that's where the confusion begins. The InternetExplorer object is an automation interface to IE. The WebBrowser control is an ActiveX control that can be hosted within an application.

MSDN documents both of them in the documentation tree under WebBrowser Control here. This leads some people to believe that the following code creates a WebBrowser control but it doesn't:

Set objIE = CreateObject("InternetExplorer.Application")

It does, however, create an InternetExplorer object. This distinction is important for a two reasons. First, because the above code will open an instance of the standard IE application which doesn't happen you create a WebBrowser control. And secondly, because the events supported by each is different.

Adding to the confusion, events supported exclusively by the InternetExplorer object aren't supported in the way you might assume. For example, if you set the StatusBar to False in your code, it will hide the Status Bar in your Automated IE instance and will trigger an OnStatusBar event. On the other hand, if you then go to your automated IE window and select "Status Bar" from the "View" menu, it will make the Status Bar visible, but it will not trigger the OnStatusBar event.