I was asked the other day about making a PDF automatically start up when a CD or USB stick is inserted into the computer.
When you want to make something autorun, you need to create a file called autorun.inf and pop it onto CD. The usual scenario is that the autorun will call a program that is also on the disk. That’s fine and dandy if that’s what you want to do.
However, if you want to open a document, like a PDF, it gets a little trickier: you have to type in the path to the executable for Adobe Acrobat using shellexecute.
shellexecute=[filepath\]filename[param1, [param2]...]
The trouble with this is that the path may differ depending on how you’ve set up Adobe, plus, Adobe have a habit of changing the folder with each new version. So even if it works on your computer, it will probably break on someone else’s.
All’s not lost though. There are some document formats that you can call directly from autorun: *.txt & *.htm files:
[AutoRun]
shellexecute="readme.txt"
UseAutoPlay=1
In this example, the readme.txt file will open automatically in your default text editor. Change the file to readme.htm and the readme.htm file will open in your default web browser.
What do you put in the html file then? Glad you asked. What you want to be able to do is show your PDF document in the web browser. The simplest way of doing this is to use an iframe. So the body section of your html file will look something like this:
<body>
<iframe src="mypdf.pdf" style="width:100%;height:100%"></iframe>
</body>
Put these three files on your usb stick (autorun.inf; readme.htm; mypdf.pdf) and your PDF will open in your web browser automatically.