Huddled Masses
The internet home of Joel "Jaykul" Bennett...
Browse: Home / RunOnlyOne – Run a single copy of an application – as administrator?

RunOnlyOne – Run a single copy of an application – as administrator?

By Joel 'Jaykul' Bennett on 11-Mar-2007

On Windows Vista, the system automatically reserves the Windows’ Logo key + Number key combinations for Quick Launch, which means that you can easily launch any of your Quick Launch applications. That is, to start the first shortcut on your Quick Launch bar, you just press Win+1, and to start the second, you press Win+2 … and so on.

Run Only One

Anyway, this made me think that it sure would be nice to have the functionality I’m used to with geoShell via the QuickLaunch hotkeys — regardless of whether geoShell’s actually running or not. So I wrote up a little app called RunOnlyOne which takes another application (and any command-line parameters for that app) as arguments and either starts that app, or activates an existing instance of it.

In other words, if you drop RunOnlyOne.exe into a folder on your computer (ideally in your path) ... and put a shortcut to Firefox or IE on your QuickLaunch bar …. you can then right-click the Firefox shortcut and edit the Properties ... put (the path to) RunOnlyOne.exe at the front of the “Target” box, and make sure you edit the icon (RunOnlyOne has no icon, and you want to make sure the icon still points at your application, anyway). Now you can click that button (or press it’s Win+# hotkey as I mentioned earlier) and it will start Firefox (or IE) — but if you click it or press it’s hotkey again later, you’ll just activate the running application, instead of starting another copy!

While I was working on that, I thought it would be nice to be able to run things as administrator using that same tool, so I put in a “-s” command-line parameter, so if you call RunOnlyOne.exe -s Notepad.exe for instance, (on Vista) you’ll be prompted to elevate, and then Notepad.exe will run with administrative rights.

Vista Sudo

Having done that … I went ahead and made a separate app: Sudo which basically does the same thing, but without the “OnlyOne” restriction, so you can use it to force-start anything as administrator. Of course, you could do that from the Start Menu searchbox by pressing Ctrl+Shift+Enter anyway, but it never hurts to have more ways. Also, sudo has a “-multi” command-line parameter that allows invocations like this:

Sudo.exe -multi "Notepad.exe C:\Windows\system.ini" "Notepad C:\Windows\win.ini"

The idea is that if you run Sudo -multi you’ll get a very ugly Unidentified Application dialog instead of the usual elevation prompt, but you’ll only get it once, because once you allow Sudo to run as administrator, it will run each application in the command line as though you’d elevated each one individually. Again, there’s lots of other ways to do this (like running an administrator level PowerShell window and launching everything from there) but I’m of the opinion that there can’t be too many ways to skin a cat.

Source code to RunOnlyOne and “Sudo”:http://huddledmasses.org/downloads/Sudo_Source.7z.

Similar Posts:

    None Found

Posted in Huddled | Tagged Development, RunOnlyOne, Software, VistaSudo

« Previous Next »

Lijit Search

Tags

.Net .Net 2008 Scripting Games Automation Bugs Design Development Funny Gadgets GeoShell GUI Huddled Masses Internet licensing Microsoft Modules My Software News Personal PInvoke Pipeline Politics PoshCode PoshConsole PowerBoots PowerShell PowerShell Functions PowerTips Rants Recommender Repository Scripting ShowUI Software Solutions Textile Tips User Group UserInterface WalkThrough WebHosting Windows 7 WordPress WPF Xml

About Huddled Masses

This is web site is dedicated to the musings of Joel Bennett (aka Jaykul) about technology, software, software development, the web, and the world.

Any resemblance of the views expressed and the views of my employer, my terminal, or the view out my window are purely coincidental. The resemblance between them and my own views is non-deterministic. The question of the existence of views in the absence of anyone to hold them is left as an exercise for the reader.

P.S.: I occasionally link to things I think are great. When I do, I occasionally find a "referral code" so I can make a little cash. I promise that I don't link to anything just because of that cash (I wouldn't cross the street for the amount of cash those links bring in, never mind write a whole blog post) ... but I do not promise that things I link to will stay great as time passes, nor that you will agree with me about their greatness!

Archives

  • April 2012
  • February 2012
  • January 2012
  • October 2011
  • August 2011
  • July 2011
  • June 2011
  • March 2011
  • February 2011
  • January 2011

Copyright © 2012 Joel Bennett.

Powered by WordPress and Hybrid.