PDA

View Full Version : Add shortcut for USB drive


thetford
02-20-2007, 10:32 PM
Hey guys,
I was wondering if anybody could point me in the right direction.

I have an app on a USB drive, I need it to place a shortcut in the start folder.

I've tried using the Shell.CreateShortcut action, maybe I just don't have it quite right. It places the shortcut, but it points to the C: drive? even thought the app is on the usb drive and I used _SourceDrive? The app was running (obviously)

Anybody? :o

longedge
02-21-2007, 12:28 PM
Is the scenario that you have an app on a USB and when you run it, you want it to create a shortcut to itself in the 'all users' or 'current users' startup folder i.e. in c:\documents and settings etc. etc.

How about posting your code.

thetford
02-21-2007, 02:03 PM
Yes, that is the scenario. When the app runs it places a shortcut to itself in the "current user" start folder. NOTE: on the code below I have the desktop shown, but that is just for testing purposes.

Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP), "Security Key", _SourceDrive.."\\lock.exe" , _SourceDrive.."\\", "", 0, SW_SHOWNORMAL, nil);

I may have changed it since I tested it, I don't remember. What happened was it placed a shortcut on the desktop, but it had the path listed as C:

Here is the problem in a nutshell, its a USB drive, so on my system it might be I: but on another system it might be D: or F: or whatever.

longedge
02-21-2007, 02:40 PM
try -

Shell.CreateShortcut(Shell.GetFolder(SHF_STARTUP), "Security Key", _SourceDrive.."\\lock.exe", "", _SourceFolder, _SourceFolder.."\\lock.exe", 0, SW_SHOWNORMAL);

That works for me, not quite sure what Windows does if it can't find an app when it's booting though.

Just checked again - see what you mean, the shortcut is created to C:\lock.exe - back to the drawing board ....

longedge
02-21-2007, 03:25 PM
Just took the dog for a walk and had a think whilst walking :D

You are building an executable file. When it runs, the runtime unpacks the whole thing temporarily to C: and so the place it is running from is actually C:

Try the code below BUT then do a build NOT to .exe but to Hard Drive Folder and into the root of your USB drive. It works then.

thetford
02-21-2007, 04:09 PM
Well, my head is done for the day, I might pick it up later tonight - I think I'll go to the gym, it's not walking the dog but maybe it will help! :D

thanks.
PS - so I need to build the project DIRECTLY to the USB drive?

longedge
02-22-2007, 01:00 AM
so I need to build the project DIRECTLY to the USB drive?

Well you don't *have* to build it to the USB you can build it anywhere but it's easiest because you would otherwise have to move it there anyway. The two important points are that it runs from the USB and it is NOT an exe.

thetford
02-22-2007, 08:16 AM
Right - I tried it, your right it works. Only it creates a new problem, this is a security program, it places activation files on the users system (well, if they have the correct serial no.)

So, now I will have to encrypt the files, or protect them in some manner.

thanks for the help, you are my only allie in this endeavor ;)

PS - Do you have\need a website? I have tons of server space leased from netfirms, I can host free of charge in return for all of your help.
Mike

longedge
02-22-2007, 12:34 PM
PS - Do you have\need a website? I have tons of server space leased from netfirms, I can host free of charge in return for all of your help. Mike

Thanks for the offer but I don't have any need. I already have more space than I use but I'll bear it in mind because you never know :yes :lol

If I understand what you are saying about the security files, you could perhaps zip them in a separate file passworded and then use the AMS Zip.Extract action when you've done your checking. Just a thought.

thetford
02-22-2007, 09:29 PM
Well, I took the plunge, upgraded to AMS6.0, at least I paid for it :wow

I haven't recieved my download link yet. probably will tommorrow :D

Just curious, what type of work do you do longedge?

longedge
02-23-2007, 04:08 AM
Just curious, what type of work do you do longedge?

I'm retired - well nearly, I have a part time job in general IT Support in our Local Education Dept. but it's one of those jobs that covers anything that needs doing in our section although I do get all the Audio, Video, Media Duplication & Database stuff :)

thetford
02-23-2007, 01:39 PM
That sounds like a pretty good deal.

Me, just trying to make it as a surveyor\contrctor. Been on my own for over a year. I like computers & programming, so I paractice with AMS and REALbasic, I've gone much further with AMS. lua scripting is so much easier than basic language. (well imo).

The things that dumb*sses like me can do with computers these days! :D
I noticed you are from UK, ever been to Thetford? That is where I am from, but I've never been there.

thetford
03-01-2007, 11:58 PM
alright, need a little more help on this project...... When the USB drive is inserted, it runs an app already installed on the PC.

PROBLEM: what if the user unplugs the USB drive & then plugs it back in - the app is still running from the first time the drive was plugged in.

How do I get the USB drive to check if the application is running before launching it?

Almost thru.... if I can figure this out I am home free for now!

longedge
03-02-2007, 02:54 AM
I would guess that the Window.EnumerateTitles action is where you should be looking. Not something I've ever used myself but it should enable you to determine if another instance of your app is already running and if so, exit.