1

Is it possible to create a shortcut that points to in-existing file in php and make it run normally in windows?

Example

makeshortcut("C:\Windows\calc.exe","short.lnk");

Then when I download the shortcut, it would open calc on my computer.

I don't have COM enabled, I do have exec() enabled, so I can run some kind of perl or python, however, lots of extensions are disabled, particlarly (pywin32 and win32::shortcut), so it would be highly appreciated if I can do this only in php or using calling another script with exec() which doesn't require me to install additional extensions.

Rafik Bari
  • 4,867
  • 18
  • 73
  • 123
  • Yeah! I forgot to mention that the file exist on the computer where the shortcut will be downloaded. – Rafik Bari Aug 25 '14 at 12:13
  • Is it in the same directory accross all computers you plan to do this? If so, just create a file manually in windows, upload to your server, and the pre-made file will be available on the site. – Alex Szabo Aug 25 '14 at 12:18
  • You need to figure out what the contents of a .lnk file are exactly and `echo` those contents; with a few HTTP headers set to initiate a file download. No existing filesystem level function is going to help you with that. – deceze Aug 25 '14 at 12:20

2 Answers2

2

The linux ln command has nothing to do with Windows .lnk files, and they are not compatible.

Here is some info on the .lnk file format.

As you can see it is not trivial to create from scratch.

liblnk library allows you to read .lnk files in Linux, but I haven't seen one that allows for their creation.

Edit:

Here is a SO question similar to yours: Generate Windows .lnk file with PHP and Creating a Desktop Shortcut Using a Web Page

Community
  • 1
  • 1
Digital Chris
  • 6,177
  • 1
  • 20
  • 29
1

You can use http://www.mamachine.org/mslink/index.en.html - a bash and c program to create a shortcut. Compile the C program for your platform and call it with the shell_exec function.

Even if the question is old, I hope it helps others.

Kound
  • 1,835
  • 1
  • 17
  • 30