Page 1 of 3

Portable .LNK files

Posted: Sat Jul 26, 2008 7:04 am
by m^(2)
Motivated by a recent Lifehacker article at the topic, I decided to do something about ubiquitous misinformation that .lnk files aren't (and can't be) portable.
Really, they usually aren't, but CAN be.
I wrote a quick and dirty program, that generates portable .lnks.
Get it.

Posted: Sat Jul 26, 2008 8:11 am
by ashghost
I get this error:

lnker.exe is not a valid Win32 application.

Posted: Sat Jul 26, 2008 8:49 am
by m^(2)
upx -d lnker.exe
It seems that UPX has troubles with it, I'll update the archive and submit this to UPX devs shortly.
EDIT: Done.

Posted: Sat Jul 26, 2008 7:20 pm
by Island Boy
m^2 said
This article is wrong,
http://lifehacker.com/399293/create-sho ... -usb-drive
you CAN create relative shortcuts. No batches are needed.
Sample: A .lnk that opens a.txt in own directory.

MIME-Version: 1.0
Content-Type: application/octet-stream; name=”a.txt.lnk”
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=”a.txt.lnk”

TAAAAAEUAgAAAAAAwAAAAAAAAEaKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAFAGEALgB0AHgAdAA
please explane the above in newbe talk, step by step.


Also how does one work this "lnker.exe" app, step by step.[/quote]

Posted: Sun Jul 27, 2008 1:10 am
by ashghost
I did some searching and figured out a workaround to make shortcuts that use relative paths. :D Unfortunately, this workaround still flashes a command window before launching the target.

To start siw.exe using a shortcut placed in the same directory, enter the following as the target:

Code: Select all

%windir%\system32\cmd.exe "/C start siw.exe"
and then enter %cd% as the "Start In" directory.

If siw.exe is in the SIW subdirectory of where you place the shortcut, the target will be:

Code: Select all

%windir%\system32\cmd.exe "/C start SIW/siw.exe"
Likewise, to link to SIW in a parallel directory:

Code: Select all

%windir%\system32\cmd.exe "/C start ../SIW/siw.exe"
The above only works on Windows NT and later. To do this on Win 95, 98, or ME, you can enter start.exe instead of cmd.exe /C start:

Code: Select all

%windir%\system32\start.exe "siw.exe"
If you want to use the same shortcuts on XP and 98, you're out of luck.



I found information on this page under the heading "file management", but it pertains only to Windows 95, 98, and ME, so I combined it with info from this page.

Posted: Sun Jul 27, 2008 1:28 am
by m^(2)
Shortcuts let you define window application's window state.
Try to run it minimized.
BTW lnker shortcuts are probably not compatible with Windows 9x, however it is possible to modify this.
Then the same shortcut will work with all Windows versions, at least since 95.

Posted: Sun Jul 27, 2008 2:53 pm
by appsuser
ashghost wrote: If you want to use the same shortcuts on XP and 98, you're out of luck.
I'm not sure, but couldn't you use nircmd.exe instead of cmd.exe or start.exe to make this run on all platforms?

http://www.nirsoft.net/utils/nircmd.html

With the "execmd" option, it won't even display anything on the screen.

Posted: Sun Jul 27, 2008 3:55 pm
by ashghost
appsuser wrote:I'm not sure, but couldn't you use nircmd.exe instead of cmd.exe or start.exe to make this run on all platforms?
You could, and I was aware of it, but you would need to have nircmd installed on every machine you use, since you couldn't have a persistent path to nircmd.exe on your usb drive.

@m^(2) Thanks for pointing that out. I had realized it myself by the time I read your post.

Re: Portable .lnk files

Posted: Sun Jul 27, 2008 5:00 pm
by alanbcohen
m^(2) wrote:Motivated by a recent Lifehacker article at the topic, I decided to do something about ubiquitous misinformation that .lnk files aren't (and can't be) portable.
Really, they usually aren't, but CAN be.
I wrote a quick and dirty program, that generates portable .lnks.
Get it.
ADDED: It seems that my server has some issues now and the link doesn't work.
Temporary download: Get it.
I figured out how to use lnker. The readme files says:

Code: Select all

lnker .\prog\prog.exe
The problem is that a command line utility would seem to need two parameters; the name of the link created and the command to be executed. So, I tried from a command prompt:
lnker linker.ink lnker.exe
and it successfully created a link - after I downloaded and installed:
msvcp60d.dll (not present on my WinXPSP2 system)

Next question might be; is there a way to create a link from the GUI without opening a command prompt window?

Posted: Mon Jul 28, 2008 1:16 am
by m^(2)
No, there's no GUI and I don't intend to write it.
If somebody wants to do it, I say: go on, I can even offer some help.

The use of MSVCP60D.dll is a bug, it should be (much more common) MSVCP60.dll instead. I'll fix it shortly.
EDIT: Fixed.

Posted: Mon Jul 28, 2008 5:39 am
by alanbcohen
Glad I could help (find a bug). I'll be monitoring the forums for some else's GUI; I'm not competent with Windows programming.

How one works lnker, step by step guide.

Posted: Mon Jul 28, 2008 7:37 pm
by Island Boy
How one works lnker, step by step guide.

1. Create a text file (.TXT) in the same folder as lnker.exe

2. Type the following to text file & save.
lnker .\prog\prog.exe
(that's the "file path" from intended link location to program file)
n.b. File path must not contain "&" (Bug?)

3. Rename the text file and change the extension to .BAT instead of .TXT

4. Run .BAT file.

Re: How one works lnker, step by step guide.

Posted: Mon Jul 28, 2008 10:58 pm
by m^(2)
Island Boy wrote: File path must not contain "&" (Bug?).
Yes, it is a bug, you can't pass this sign in a command line unless it's enclosed in double quotes ("a&b.exe"), but such parameters aren't handled by lnker.
It's a minor thing and I don't intend to fix it though, sorry.
ADDED: I found a workaround. Create a shortcut to lnker.exe (usual, not portable one) and in the "target" field type:
C:\lnker.exe a&b.txt

Seems to work well, but ...

Posted: Tue Jul 29, 2008 5:58 pm
by Island Boy
Seems to work well as long as lnker.exe is not placed in any folder,

e.g. C:\lnker.exe or F:\lnker.exe or the like.

I can live with it.

Posted: Wed Jul 30, 2008 3:36 am
by m^(2)
What is the problem when it's in a directory?
There shouldn't be any issues.