Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 07, 2016, 10:34:01 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: How to create relative shortcut for a USB drive?  (Read 5363 times)

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,070
  • Is your software in my list?
    • View Profile
    • Donate to Member
How to create relative shortcut for a USB drive?
« on: May 01, 2009, 12:12:22 PM »
Since I'm trying to create a portable workstation on my USB stick, I'm running into this issue.

I need a way to create a shortcut that will launch my launchers.  Let me explain.  I'm going to use FARR and LBC as my portable application launchers.  However, when I first insert my USB stick, I'd like to be able to immediately launch those two from the root directory, even though their program files are elsewhere on the drive.  So, I need the shortcut to be able to handle relative paths, which Windows can't do.  Now, FARR and LBC can both handle relative paths, so that's not the problem.  That's why I say I need a shortcut to launch those launcher programs.

Anyway, I found this article:
http://www.freewareg...r-use-on-usb-drives/
And it works great, except for one thing:  The DOS window that pops up (because it's a bat file) won't close until the program it launches closes.  Not a big problem, but annoying.

So is there an alternative solution anyone can think of?  Maybe using an AHK script or something like that?  Or is there a program that already does things like this?

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #1 on: May 01, 2009, 12:26:03 PM »
I am assuming you have autorun disabled, otherwise, that is your answer.

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,070
  • Is your software in my list?
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #2 on: May 01, 2009, 12:27:24 PM »
I am assuming you have autorun disabled, otherwise, that is your answer.
Oh yeah, i forgot to mention that.  I want it to work on computers regardless of autorun.

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,184
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #3 on: May 01, 2009, 12:42:38 PM »
2superboyac

What about using BAT files without compiling them?

You could write in them something like (for DifRes.exe application in "ala" path):

start "" "%~dp0ala\DifRes.exe"

This way CMD window will disappear automatically. %~dp0 is always replaced with the path to BAT file.

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,070
  • Is your software in my list?
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #4 on: May 01, 2009, 01:02:17 PM »
^^that works fenix!  But I thought it was cool to get the icon embedded in the file as well, like the compiled version.  Of course, your code doesn't work when compiled.

I know I'm being nitpicky.  Basically, just for the fun of it, I'm wondering if this can be done perfectly.

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,070
  • Is your software in my list?
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #5 on: May 01, 2009, 01:03:58 PM »
Couldn't this be done in AHK?

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,070
  • Is your software in my list?
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #6 on: May 01, 2009, 01:07:02 PM »
Found the solution:
Quote
Ok, if you guys don’t want a black DOS windows to pop up. Then, when you are making the conversion, check invisible application instead of visible application (the default)

It's in the comments of the link above.  Awesome!!

fenixproductions

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,184
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #7 on: May 01, 2009, 01:08:25 PM »
2superboyac
Other solution is to use AHK.

With its Ahk2Exe tool you can compile simple script and choose your icon for it.

So if you want hardcoded solution then write your own script:

Run "ala\difres.exe"

PS. I wonder how mentioned BAT compiler works. I think I can be 90% sure that on startup it simply decompiles BAT file into TEMP and runs it from there.
« Last Edit: May 01, 2009, 01:11:25 PM by fenixproductions »

jjooeh

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #8 on: June 07, 2009, 11:16:27 PM »
I wanted to do this about a year ago. I tried many different things that I found in forums and such. It was all too much of a pain so I just gave up.

About 5 minutes ago I was getting ready to go to sleep and had a "eureka!!" moment and thought "no, it can't be that simple."

Apparently it is.

Here's what I did:
created a shortcut the normal way. (right-click)

Then opened notepad++ and dragged that new shortcut into notepad ++ and dropped it.

It displayed a bunch of gibberish, but there in the middle was the path to my exe in plain text.  "E:\programs\firefoxportable\firefoxportable.exe"

I simply typed a relative path over it. ".\programs\firefoxportable\firefoxportable.exe", (replaced 'E:\" with ".\" and clicked save.

So far it seems to work just fine. I'm using XP pro. Apparently it has no problem recognizing relative paths but the program that creates them when you right click and select "create shortcut" just won't allow it.

EDIT:

Tried this on a different PC at school and it doesn't work.  :-[

« Last Edit: June 08, 2009, 04:50:56 PM by jjooeh »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,408
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #9 on: June 08, 2009, 12:42:13 AM »
nice find jjooeh  :up:

another way to solve this would be if someone makes a nice commandline tiny coding snack exe that takes a path to a program as an arguement, and launches it with some smart fixing up.

for example imagine a commandline tool:

SmartLaunch.exe

You would call it like

SmartLaunch.exe "..\MyRelativeApps\mytool.exe" "arg1" "arg2"

and it would fixup the "..\MyRelativeApps\mytool.exe" to point to the right place and launch it with optional arguements.

it might also support fixing up bad drive letters so if you did
SmartLaunch.exe "C:\Apps\mytool.exe" "arg1" "arg2"
and the tool was on a removable drive that changed from C to D then it would be smart enough to detect that and launch
"D:\Apps\mytool.exe" "arg1" "arg2"

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,258
    • View Profile
    • Coding Snacks by Lanux128
    • Read more about this member.
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #10 on: June 24, 2009, 06:21:36 AM »
Anyway, I found this article:
http://www.freewareg...r-use-on-usb-drives/
And it works great, except for one thing:  The DOS window that pops up (because it's a bat file) won't close until the program it launches closes.  Not a big problem, but annoying.

that can be easily fixed. you just have to set 'Visibility' to "Invisible application".

SC_24_06_2009_001.png

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 2,927
    • View Profile
    • Donate to Member
Re: How to create relative shortcut for a USB drive?
« Reply #11 on: June 24, 2009, 09:07:46 AM »
You might try Horst Schaeffer's Qsel or PopSel launchers.  Both have automatic drive letter handling on flash drives, CD-ROMs etc.

[Edit]
Magic number; just made post number 1,234.
[/Edit]



« Last Edit: June 24, 2009, 09:09:20 AM by rjbull »