My Elevate-Process Script

I used to use the Script Elevation PowerToys to provide a simple way to launch an elevated command window from a Powershell prompt. However, that required installing said PowerToys in order to work, which I invariably forgot to install when paving my machine. That got annoying, so I went in search of a pure Powershell solution, which Peter Provost conveniently provided on his blog.

However, one of the benefits of the Script Elevation PowerToys was the ability to launch an admin command prompt in a specific directory – including the current one. I wanted the ability to default to launching Powershell when the user doesn’t specify a command to run. I thought I could just set $psi.WorkingDirectory, but as I’ve described previously, I update $home in my profile script to D:HPierson.Files (I keep my important files on my D: drive so I can pave C: with impunity) then set my current location to $home. So I can’t set the current location by using $psi.WorkingDirectory – it just gets overridden by my profile script.

However, it turns out you can pass arbitrary script code to Powershell via the –Command arguments. You also have to pass –NoExit to keep the command window around. The script passed in via -Command is executed after the profile script, so I can pass in a little script code to set the current location to the right location.

I modified Peter’s elevate-process script to launch a new Powershell command window when zero arguments or one folder argument are passed in. In those cases, elevate-process sets the location to the specified directory (current directory as the default when no arguments are provided) via the –NoExit and –Command arguments.

I’ve posted the script to my SkyDrive as well as providing it below. Feel free to steal use it as you need.

function elevate-process  
{  
  $psi = new-object System.Diagnostics.ProcessStartInfo
  $psi.Verb = "runas";

  #if we pass no parameters, then launch PowerShell in the current location
  if ($args.length -eq 0)
  {
    $psi.FileName = 'powershell'
    $psi.Arguments =  
      "-NoExit -Command &{set-location '" + (get-location).Path + "'}"
  }

  #if we pass in a folder location, then launch powershell in that location
  elseif (($args.Length -eq 1) -and  
          (test-path $args[0] -pathType Container))
  {
    $psi.FileName = 'powershell'
    $psi.Arguments =  
        "-NoExit -Command &{set-location '" + (resolve-path $args[0]) + "'}"
  }

  #otherwise, launch the application specified in the arguments
  else
  {
    $file, [string]$arguments = $args;
    $psi.FileName = $file
    $psi.Arguments = $arguments
  }

  [System.Diagnostics.Process]::Start($psi) | out-null
}

Update: I tried to run my elevate-process script from c:Program Files and discovered a bug. The set-location scripts need the path parameter to be encapsulated in single quotes in order to handle paths with spaces. I’ve updated both the code above as well as the copy on my SkyDrive.

Election Predictions

Is it to early to start making predictions about 2010, 2012 and beyond yet? Probably, but I’ve got a few thoughts anyway.

First, if Obama runs his presidency like he ran his candidacy, he’ll be a great president and will win reelection in a cakewalk. Obviously, there are huge challenges ahead, but I have faith his administration will be able to handle them.

Second, assuming prediction #1 pans out, we’ll see another wide open race in 2016. I’m a big Joe Biden fan, but he’ll be 74 in 2016 – two years older than McCain is now. No way he runs. Hillary Clinton will 69 so I don’t see her running either. Well, maybe they run but I doubt they’d win the nomination. I’m guessing the Democratic nominee in 2016 will be someone who’s not top of mind today – someone who emerges in the next two or four years as “the next Obama”.

Third, we haven’t seen the last of Sarah Palin. I’ve been extremely critical of her, but my libertarian friend recommended I not underestimate her. So I won’t. I think she’ll be the Republican nominee for president in 2016. I know folks are talking about her for 2012, but I think she’d rather take her chances in a wide open race in 2016 than go up against Obama a second time. She’s only 44 now, so she’ll be 52 in 2016 – about perfect for a presidential candidate. Eight years is a long time for her to close the unqualified gap.

In fact, I’d say Ted Stevens apparent reelection is a likely silver lining in otherwise crappy election for the Republicans. Ted Stevens was found guilty on felony corruption charges and faces expulsion from the senate, regardless of his apparent victory yesterday. If he is expelled, there would be a special election to decide his successor. You have to assume Mark Begich, Stevens’ Democratic challenger, would handily win that special election. But what if Palin ran against Begich? She’s taken a hit it her approval ratings since joining the VP ticket, but she’s still very popular in Alaska and probably liked best by Stevens’ supporters. I’m not saying it’s a shoo-in, but I believe she’d have a very good chance to win a special election.

Being a senator for eight years would be long enough to shore up the concerns about her qualifications but short enough not to have much of an attackable voting record. She’d have to win reelection in 2014, but given that Stevens has won seven elections in a row dating back to 1970, I’m guessing getting reelected in 2014 would be no problem.

So my predictions are a fairly easy Obama reelection in 2012, followed by Sen Palin (R) vs. “The Next Obama” (D) in 2016. Midterms in 2010 will probably see Dems give back some of their recent gains, but not enough to lose control of either house of Congress. 2014 is to far out to predict, much less who wins in 2016. But looking at voting trends among minorities, party ID advantages, etc, I like Democrats chances for the foreseeable future.

Finally, I wonder if this is the “end of identity politics” as some have suggested. One election is not a trend, so I tend to think that Obama was immune to such attacks more than those attacks no longer viable. We may need to wait until 2016 to find out. When Palin does run again, will she still be a pitbull with lipstick? I like to think identity politics is toast, but I’m guessing the Republicans will go back to that well a few more times before giving up on it. Democrats, on the other hand, have all the proof they need that they can win against identity politics: President-Elect Obama.

Yes We Can

What a difference four years makes. In 2004, I was up until the wee hours because Ohio wasn’t called until the following morning. This year, with Pennsylvania called at 8pm EST and Ohio about 90 minutes later, it was basically over before my kids finished their dinner. We were watching SNL on the DVR from last night when my Dad called to tell us the nets had called it for Obama.

As I write this, Obama has 349 electoral votes – 79 more than he needed to win – with three states still to be called. It looks like Obama will pick up North Carolina (ahead by 12,160 votes with 100% of precincts reporting). Montana looks to be going for McCain (he leads by 7,000 votes with 77% reporting) and Missouri looks like a true tossup, with McCain ahead by a scant 1,740 votes with 99% reporting. Assuming those leads hold up, that would give Obama 364 EVs to McCain’s 174 EVs. Compared to the last two elections, that’s a good solid win on par with Clinton’s win in 1992 (370-168) but nowhere near the ass-kickings by Regan in 1980 (489-49) or 1984 (525-13) or Bush 41 in 1988 (426-111).

(BTW, check out the electoral college map from Carter’s win in 1976. It looks like Bizarro’s electoral map. The south went all blue while California went red? Can you even conceive of that happening today?)

But even though it wasn’t 500 point blowout, consider that Obama flipped all the following red 2004 states to blue in 2008: Virginia, Florida, Ohio, Iowa, Indiana, Colorado, New Mexico, Nevada and (probably) North Carolina. My parents are very excited to live in a blue state (VA) now. McCain on the other hand flipped none – goose egg – from blue to red. McCain’s only real hope was Pennsylvania and it wasn’t even close – Obama won PA by 9%.

I did like McCain’s concession speech. Obviously, with the president around 25% approval rating, the incumbent party is at a major disadvantage to start with. But of all the Republican candidates, McCain was the only one I was ever worried about. IMO, any of the other Republican possible nominees would have lost by a much worse margin. McCain was attractive to independents in a way no other Republican candidate this year was.

But in the end, McCain had the probably impossible job of pulling together the 25% of Americans who approve of Bush (politely called “the Republican base”, though I call them “wack-jobs”) with another 25% of Americans who don’t. Kinda like trying to push like charged magnets together, they just wouldn’t stick. To me, it seemed like McCain tacked hard right and prayed the independents would still support him. But as I watched McCain’s concession speech, it made me wonder if McCain could have won by running an honorable campaign, tacking to the center and hoping the conservatives would still support him. Maybe they would, maybe they wouldn’t, but he ended up running as a hate-mongering Rovian erratic demagogue and significantly damaged his personal brand. I can barely reconcile McCain from the stump with McCain from the concession speech. I’m guessing he’ll retire instead of running for reelection in two years.

(I’ve also got thoughts on Palin’s political future, but those will wait for another day.)

As for President-Elect Obama, I’m obviously excited than he won. Patrick made me promise to tell him who won in the morning (it wasn’t official until the west coast results came in after he went to bed). I’m going to show him Obama’s victory speech – it was amazing. I especially liked when he said “And to those Americans whose support I have yet to earn – I may not have won your vote, but I hear your voices, I need your help, and I will be your President too.” My libertarian friend who thought it would break for McCain today (way, way wrong dude) immediately went political, pointing out that the Democratic “trifecta” means they can’t shift the blame if things get worse. I’m guessing Obama will have to do quite a bit to earn my friend’s support but I’m hopeful that he can.

In other races I’m following, looks like Gov. Christine Gregoire will win reelection and Darcy Burner is leading in her race to unseat Rep. Reichert (though with only 21% reporting so it’s far from sure thing). In California, Prop 8 to ban gay marriage is currently leading but with only 51% reporting so I’m hoping that changes. (Amending the constitution in CA doesn’t require a super-majority? That sucks).

Finally, a quick shout out to my friends from New Zealand that I hung out with after the Opshop concert at the TechEd Attendee party back in September. They confided in me that “everyone in the world” was pulling for an Obama victory. Based on this Global Electoral College from the Economist magazine, “everyone in the world” is pretty close to spot on. Happy that my fellow Americans and I could deliver an Obama victory. Feels good, doesn’t it?

Election Day 2008

(Editor’s note: almost every time I make a political post, some yahoo, typically anonymously, suggests that I “stick to technology”. I will remind you, dear reader, that This Is Not A Technical Blog. If you don’t like my politics, you’re free to ignore the political posts or simply unsubscribe from my blog altogether. Anonymous suggestions as to what I should or should not be blogging about will be summarily ignored.)

Jules and I voted this morning, before work and school. Patrick helped Julie vote and Riley helped me vote. I’m assuming regular readers don’t need to be told who I voted for. Riley just wanted to help fill in the bubbles because it’s like coloring. Patrick kinda got what was going on – check out Jules’ post about how they cast “our” vote.

For shits and giggles, I went back and looked at my posts from two years ago. It doesn’t make me Nostradamus, but I did guess we were going to have “a very ugly race, especially from the Republicans” and that “the nomination race will be worse” than the general election. If Keith Olbermann or Rachel Maddow want to get in on this insightful political analysis, they know where to reach me. 😄

I’ve been obsessed with three polling sites over the past few months:

My wingnut libertarian friend (anyone from my kids’ playgroup who reads this blog can guess who I’m talking about) thinks McCain will win with “295-305” electoral votes. This election is far from being in the bag for Obama, but the suggestion that McCain will come from six or seven points down in the polls to win a 10-20 point bigger EV victory than Bush did four years ago seems like crazy talk. As for me, I’m not willing to make a firm prediction except to say that I think the polls are wrong – I’m just not sure in what direction they’re wrong.

On the one hand, if the polls are underestimating Obama’s support by excluding cell-phone only voters and Obama’s Get Out The Vote effort is as strong as it looks, that could net Obama as much as five or six points on top of the lead he’s already got and we’ll be looking at an epic landslide with Obama maybe brushing up against 400 EV. For example, Pollster.com’s 291 solid/lean Obama EV + 105 toss up EVs would be 396 total EVs for Obama.

On the other hand, if the polls are overestimating Obama’s support due to the Bradley Effect, the undecideds break for decisively for McCain and Obama’s GOTV effort doesn’t materialize, McCain’s might net those five or six points and turn this into a toss-up squeaker decided by less than 35 EV (about the size of Bush’s victory in 2004). For example, if McCain wins all of Pollster.com’s tossups + the lean Obama states, it’s a scant 8 EV Obama victory (273-265). If McCain could also pick off any of New Mexico, Colorado, Iowa or Pennsylvania in that scenario, then he would win by anywhere from 2-34 EVs.

Of course, those effects could cancel out and leave us where we are right now, Obama with a six to seven point PV and low 100s EV victory. Frankly, I’ll be happy to be wrong about the poll inaccuracy since that would give Obama the presidency.

How do you think things are going to play out today?

I Survived October

It’ felt touch and go at times, but I did manage to make it thru PDC prep, PDC itself, shipping IPy 2.0 RC1 and Halloween relatively unscathed. I was Superman for Halloween – the perils of letting the five year old pick everyone’s costume, we we’re *all* Superman (well, Jules and Riley were Supergirl) – but given how exhausted I was, I could have skipped the costume and just gone as a zombie.

My inbox is currently just under 500 messages, I’ve got a mountain of stuff to finish for IPy RTM, I’m presenting at the p&p Summit and I’m finally get some attention from the legal dept (now that we’re past PDC). In other words, it’s not the end of PDC is ushering in a golden age of zero work for Harry. But with PDC in my rear view mirror, I don’t feel quite so overwhelmed as I did.

And on top of all this, I’ve been borderline obsessed with election news. I’ve basically given up on all my non-political blog reading – if I hadn’t been working on PDC I might not have even been aware of the big announcements like Oslo and Azure. Things are looking good for Obama and the Democrats, but as this hilarious video shows “Being in a good position to win is not the same as winning.” I haven’t had the time to volunteer for Obama but my father has been volunteering for Obama in Northern Virginia – aka “communist country”. It sure would be nice to see my home state go blue.