Thursday, June 24, 2004

Launched from a shortcut?

If you would EVER need a way to check if your application was launched from a shortcut, rather than accessing the EXE itself, this article should help.

Now why you would want to do this is, frankly, beyond my imagination. The only thing I can think of is that on XP/2000, you can choose to run a program with different credentials through a shortcut. Even here you can't specify the credentials - the user gets to choose them (and enter a username/password) And the user can actually choose the *same* credentials as the logged on user, even with this flag set.

This is the programming equivalent of saying "There may be someone else on the computer right now, or maybe not.". Which might not be the lifesaver we're all looking for. (And no, we don't get them in India. The famous mints here are "polo" and "minto", if you're curious. Which you probably aren't, but I'm bored to death of the programming stuff) If anyone knows what scenerio such code might be useful in, I'd really appreciate a hint...


Blogger Craig Murphy said...

Interestingly, one of my client organisations rely on the use of shortcuts.

Indeed, when I roll-out InterBase to their PCs, it is installed whilst logged in as Administrator. My application is installed as a user login.

However, there has been the odd occasion when I needed to fire up InterBase to make some SQL tweaks. In this organisation, I can only run InterBase via a shortcut from the user's login.

If InterBase was my application, would I like to know if I'd be fired up via a shortcut? Perhaps for security, environment permitting of course, I may like to force users to run part of my application whilst logged in as Administrator, thus running the app via the .exe.

In the InterBase organisation I mention, it would be possible to manually create a shortcut that runs an application in another user's Program Files: there is security in place to stop them going overboard with this, though!

I use shortcuts as a means of specifying different working directories with different .GDB files: here's where it may be useful to know if your .exe started it's life as a shortcut, especially if you don't have a fixed installation directory. Same application, different working directories. Still not a definitive answer...but food for thought.

Like you, I can't really see much need for it: hence it appears in a "undocumented features" article - Microsoft either forgot about it, or have already considered its worth!

Here in the UK, we have Polo and Fox's "Ex ex ex" mints(pronouced triple Ex, and spelt as in the letter X)...I prefer the latter as the former have laxative effects..too much information. I'll stop now.

2:05 AM  
Blogger Deepak Shenoy said...

I guess there are the advantages of shortcuts for users, like you said - different working directories and different credentials (the latter can be supplied by a "runas" command also). From an application point of view, it's probably not very important to find out what you used to access it.

Come to think of it - what if an application was run "remotely" through a shortcut? Could I find out where that shortcut was, and if it's on a desktop, actually identify the user's login? (the path to the desktop on Win2k/XP will have the login) Assuming of course that this is not the user that logged in to the remote machine. Have to check.

8:55 PM  

Post a Comment

<< Home