Hey, I was wondering if anyone knows a way to type a directory which points to the current USB drive, regardless of which actual Physical Drive Letter any given Computer assigns it
For example, I want to create a Shortcut to a file, but as soon as you move to another computer where the USB is assigned a different letter than the letter it was created on, the Shortcut no longer works
For instance, when I create a shortcut pointing to:
I:\My Portable Programs\Apps\Cool Program.exe
will not work on a computer where I plug it in and its F:\, since the address is no longer pointing to anywhere that exists on that computer
can I do something like %dir%\My Portable Programs\Apps\Cool Program.exe or something similar to make the shortcut always work when its launched from its own current directory where it currently resides?
i suppose this must be common in Portable programs, or else it'd be hard to get them to work on all computers
thanks for any help
Well, the way that the launcher works, it takes into account a few special Environment variables that are unique to the launcher. You can find a list of them here. The vast majority of them won't work in normal shortcuts, so keep that in mind. If you're planning on making a program even semi-portable, it might be better in the long run to use the launcher since it's a little more versatile.
Depends on the location of the shortcut:
Yes, I set the working directory!
If you are willing to use a Batch File, in the past I made a batch file that did what you are after. (ran a program regardless of changes to the drive letter)
If I understand my Batch file correctly (I copied and pasted from the 'net and it works [on XP SP3 computers], but I'm not 100% sure why :-p)
using your example (I:\My Portable Programs\Apps\Cool Program.exe)
a batch file (on the same USB Drive) containing
should launch Cool Program.exe no matter what the drive letter is.
note: if the folders/file name contain a space you *DO* need to put the " at the beginning and end of the line.
That batch file will leave a dos window open while the program is running. (well, it does for me)
The way I've found to get the dos window to close is to use START command.
Yes, the "" between start and %drive% is necessary.
Please be aware that START is also use to run multiple programs in a batch file at the same time (batch files, when starting a programs this way, will wait until the first program closes before running the next one)
ps: one other fun thing I did with my batch file was use a 'BAT to EXE' converter program to turn it into an EXE file, which the PortableApp Menu will recognise and add to its list of programs :-). The only downside to this is every so often an anti-virus program with detect one (at random it seems) of the BAT>EXE files I've made as a threat and delete it
apologies if that doesn't work for you or if I have explained it badly.
Good luck
The %drive% variable ain't necessary, you could also use relative paths (it starts from the current working directory or you could use %~dp0).
Also, this only works if the bat file is located on the same drive as the program.
As for your batch file (since you didn't understand what it did...):
REM everything that starts with REM is a comment :)
REM sets the "drive" variable to the drive part of the path (d:\, e:\, ...)
set drive=%cd:~0,3%
REM prints the drive to the command line, you can remove this if you want.
echo %drive%
REM start has 2 required parameters, the window title and the path.
start "" "%drive%My Portable Programs\Apps\Cool Program.exe"
Yes, I set the working directory!
thanks guys
so I guess Relative & Batch files are both good ways.. but then there's inherently another problem with both..
the Icon itself is lost when the drive changes as well
anyone know how to keep the original Icon?
can you use the Launcher to install any stand-alone program, like a stand-alone.exe portable program, in a quick & simple way?
or use the launcher just to install a shortcut to a program?
or is there any program that just handles shortcuts & their respective icons?
I REALLY dont want to change all my icons to default windows system icons
Thanks
Well, I used "Bat to Exe" which allows you to bundle an Icon file & create an *.Exe file from a Batch file...
I didnt get it to work with a simple:
My Portable Programs\Apps\Cool Program.exe, as the program suggests..
but when I made the batch which u guys suggested:
-----------------------
set drive=%cd:~0,3%
echo %drive%
start "" "%drive%My Portable Programs\Apps\Cool Program.exe"
-----------------------
it worked, but the dos window popped up for a second.. not a big problem
@benniboj: what do you type exactly if %drive% isnt needed?
can you post an example of a script that would keep the window closed?
anyway, its a great solution to create shortcuts while keeping the Icons, so I'm happy with it
also, theres a portable program called "Pstart" which installs portably to your USB drive, and allows you to browse or search for .*exe files on your USB drive to create a custom menu filled with any number of your programs, whether they installed from the portableapps.com platform or not
so thats a pretty cool way to go as well..
This is what I have:
start "" FreeFileSyncPortable\FreeFileSyncPortable backup.ffs_batch
You can go back to the root of the drive using "..".
So
start "" ..\folder\awesome game.exe
opensJ:\folder\awesome game.exe
if the bat file is located inside another folder of the drive
(like e.g. J:\myshortcuts).
Also: BatToExe programs useually use UPX to compress the exe. This is mistaken for a false positive most of the time, so I don't use these programs anymore. Just so you know, your exe might get deleted.
Yes, I set the working directory!
-------------
QUOTE::: This is what I have: start "" FreeFileSyncPortable\FreeFileSyncPortable backup.ffs_batch
-------------
what do you mean, "thats what you have"? is that an example of a file you are using? what is *.ffs_batch?
-------------
QUOTE::: You can go back to the root of the drive using "..".
So
start "" ..\folder\awesome game.exe opens J:\folder\awesome game.exe
if the bat file is located inside another folder of the drive
(like e.g. J:\myshortcuts).
-------------
you say: "..".
But you type: "" ..\
what does that mean? why are you saying two completely different things there?
and are you saying "" ..\game.exe will find the game.exe file in any folder on the USB drive, no matter how many levels down it is in the folder structure?
-------------
QUOTE::: Also: BatToExe programs useually use UPX to compress the exe. This is mistaken for a false positive most of the time, so I don't use these programs anymore. Just so you know, your exe might get deleted.
-------------
and what do u mean "Mistaken for a False Positive 'Most of the Time'"?
what/who would delete the exe file? do you mean in antivirus programs?
I dont delete anything automatically, and I believe all of the computers I use dont either.. I'm not required to scan my entire USB before I use it, since I mostly use them on Ghost OS's which are in no way affected by any viruses anyway... so i think it'll work.. I suppose maybe you could rename the file from .exe to .abc or something until after the scan, not sure if that'd work though or is worth the trouble
anyway, thanks for the input
1) Yes, that's an example of how I use it in real life. The *.ffs_batch is a command line parameter that I pass to FreeFileSyncPortable, it's just an example. If your program doesn't need any command line parameters, ignore this. Also it doens't have anything to do with a *.bat file
2) What I should have said is this: You can go one level up in the hierachy by using two dots (..). Eventually you'll end up at the root of the drive. I only put the quotes around it to make it clear but apparently it confused you, sorry.
In here, the path can contain the double dots, like in my example with FreeFileSync.
If you understood what I just said, this question should be irrelevant
3)Yes, I meant antiviruses. Not all antiviruses are equally forgiving nor user friendly Also, just by renaming a file, it'll still get deleted. You might not be able to use your programs on a public pc or a pc with another antivirus.
Yes, I set the working directory!
well, you'll still be able to go to the directory and click the original .exe file anyway, if you have to.. but its nice to not have to when you dont have to.. anyway, i quite like Pstart as well.. it takes some time to get set up, and grouped, and get rid of executables you dont need, and add all the ones you do.. but once you do that, it has a back-up function, and looks right good..
well, i tried your method but I kept getting errors
are you saying you can put as many double dots as you want? and that: ...... would go up 3 levels?
anyway:
works right well
thanks
Yes, you could just click the exe, but OP asked for a "shortcut like" solution
Never used Pstart...
..\..\..\
Goes up 3 levels. It's basic command line logic (ms-dos on windows), google it, you'll learn a lotYes, I set the working directory!
well, at any rate, I live in a region where practically nothing in the entire country is set to ever delete anything automatically, due to various political reasons..
so I am not likely to ever find a computer that would invade my USB & permanently delete anything it wants to.. which i'm thankful for..
in fact, there's only a couple programs that are set to do that by default, Microsoft Security Essentials, & Norton AV are two that come to mind, and I'd never use either, neither would any IT / Admin guy in any company or location I've ever been.
And, as I mentioned, most computers have Ghosted all Drives anyway, so you can never leave a byte of your own information on the computer anyway.. they dont care if you upload viruses all day long...
and the ones that dont ghost everything, have the good sense not to allow invasive quasi-AV programs to destroy files for unrelated Private Corporate Interests & what not..
Since most AV's which destroy files permanently by default are created as such to rid the world of perceived pirated material, keygens, cracks and other such stuff... so there's an inherent conflict of interest between a users Private Files & and certain AV's ulterior agenda.. and any IT guy worth his salt would definitely not have any such AV installed. at least I've never met one or a come across a properly administrated computer which does..
but thats me, i have no idea what / where you find them in play or where you use computers.
but anyway, so ya, this solution works absolutely GREAT for me, and probably will for most people on the planet. I'm VERY happy to have found this method of Creating Shortcuts & retaining their Icons on Relative Paths for Portable Storage Devices
and thanks for the information on batch scripts.. but, seriously, if I put every one of your posts together, I still would not have enough information for a single example of a working Batch script..
maybe you can just give the entire batch script that you believe works, from start to finish, for a file located at J:\My Portable Apps\Games\Cool Game.exe - otherwise, thanks anyway
Anyone know how to / if you can can use Shell Execute from a USB ?
I tried:
set drive=%cd:~0,3%
echo %drive%
start "" "%drive%Portable Apps\ShellExecute.exe /F:start "Portable Apps\Start.exe" /R:hidden
but that didnt work, something wrong with the syntax maybe, a DOS windows launches, but something wrong with the location to Start.exe..
thanks
at a guess, the problem is you have a odd number of " in the line.
one before %drive%
one before Portable Apps\Start.exe
and one after Portable Apps\Start.exe
I'd try taking out the " before Portable Apps\Start.exe and see if that works.
and if it doesn't I'd put it back and add a " after /F:start
ps: if you add a line in your batch file that says
it will wait for you to push a key before it continues. I have found that a good way of looking at error messages when I make BAT files. (and then take it out when I am happy with the BAT)
I hope that helps
it seems the problem is in the bat file itself
shellexecute is designed to run via cmd line.. and your program would need to have that function in order for it to launch hidden..
meaning, Bat files dont do that.. they need to pop up a window before accessing the Command Line..
you'd need a program that allows access to cmd, might look a bit like Pstart
or you'd need to use VB to program a shellexecute command, bundle the icon, and pack it as an exe file.. like writing your own program..
it'd be cool if there was a program tat could do that