This post from Walter Zackery shows how to create shortcuts using .INF files and RUNDLL:
From: Walter Zackery (walter_zackery@my-Deja.com) Subject: Creating LNK shortcuts from a batch file without Shortcut.exe Newsgroups: alt.msdos.batch Date: 1999/12/02 I didn't think that it was possible, but today I finally had a breakthrough in getting a batch file to programatically create LNK files (shortcuts). The secret lies in one of the best-kept, most mysterious secrets in Windows, the INF file. I've always puzzled over how it is that installation programs manage to create Start Menu shortcuts, and after a careful examination of the INF file structure, it finally dawned on me how they do it. If you look at a inf file for a program that's been installed on your system, you may see a section that looks something like this: [AddLink] setup.ini, progman.groups,, "group0=%ShortName%" setup.ini, group0,, ""%ShortName%"" setup.ini, group0,, """%icon1name%"",""%49002%\jscript5.chm"",,0," This may look like jibberish, but that's the sort of syntax that programmers use in an INF file to create start menu shortcuts. Once you divine the syntax, you can easily create a start menu shortcut to any file or folder on your system and then move it from the start menu to the folder of your choice. That's exactly what the following batch file does. It takes four parameters, which must all be passed to the batch file, and in exact order. Parameter number one must be the complete path of the file or folder that you're trying to create a shortcut to. Parameter number two must be the complete path of the folder that you wish to locate the shortcut in. Parameter number three is the trickiest. It must be the complete path to the Programs folder. The Programs folder is the folder that contains your Start Menu shortcuts. It's normal location is c:\windows\start menu\programs, or possibly c:\windows\profiles\xxx\start menu\programs, where xxx is your user name if you're using profiles. It's possible to obtain the location of the Programs folder using a batch file, but doing so would more than double the size of the batch file, so I refrained. Parameter number four must be the name that you wish to give to the shortcut. Don't attach the LNK extension to this name, because Windows will do it for you when it creates the shortcut. Here's an example command line for the batch file. link.bat c:\windows\notepad.exe c:\windows\desktop "c:\windows\start menu\programs" "A Notepad Shortcut" When the batch file is run with those parameters, it will create a shortcut with the name "A Notepad Shortcut". The shortcut will point to c:\windows\notepad.exe, and it will be located in the c:\windows\desktop folder. Note that parameters that contain spaces must be enclosed in quotation marks. This batch file is for Windows 95/98 only. I will post the NT equivalent in the NT newsgroup soon. @echo off ::A batch file for Windows 95/98 that creates LNK shortcuts. ::Author: Walter Zackery ::December 2,1999 if %4[==[ goto syntax if not exist %1 if not exist %1\nul goto syntax for %%? in (%2 %3) do if not exist %%?\nul goto syntax %5 %0 %1 %2 %3 %4 rem "{newfolder}" InstallHinfSection echo > %temp%\#path#.bat path %path% path %1 echo > %temp%\#k#.inf [version] echo >>%temp%\#k#.inf signature="$chicago$" echo >>%temp%\#k#.inf [DefaultInstall] echo >>%temp%\#k#.inf UpdateInis=Addlink echo >>%temp%\#k#.inf [Addlink] echo >>%temp%\#k#.inf setup.ini, progman.groups,, "group0=%6" echo >>%temp%\#k#.inf setup.ini, group0,, ""%6"" echo >>%temp%\#k#.inf setup.ini, group0,,""%4",""%path%"",,0," for %%? in (call del) do %%? %temp%\#path#.bat start/w rundll setupx.dll,%7 DefaultInstall 132 %temp%\#k#.inf del %temp%\#k#.inf move "%3\{newfolder}\*.*" %2 > nul rd "%3\{newfolder}" goto end :syntax for %%? in (cls echo[) do %%? echo Four parameters must be passed to the batch file, and they echo have to be passed in exact order. Do not put backslashes at echo the end of any parameter that is passed to the batch file. echo All long filename paths must be enclosed in quotation marks. echo[ echo The first parameter must be the name of the file or folder echo that you are trying to create a shortcut to. echo[ echo The second parameter must be the location of the folder echo in which you want to place the created shortcut. for %%? in (pause cls echo[) do %%? echo The third parameter must be the location of your Programs echo folder. The Programs folder is the folder that holds most echo of your Start Menu shortcuts. It's normal location is echo C:\windows\start menu\programs. If you are using profiles echo then its location may be echo c:\windows\profiles\%%username%%\start menu\programs, where echo %%username%% is your user name. Note that if you list the echo wrong location for the Programs folder, then the shortcut echo will be created, but it will not be moved to the folder echo that you specified. Instead, it will remain on the Start echo Menu in a folder named {newfolder}. echo[ echo The fourth parameter must be the name that you want to give echo to the shortcut. Do not add an extension to the name unless echo you want the extension to be part of the shortcut's name. :end
This post was later followed by an NT version.
More information on .INF files and shortcuts can be found in this article by Daniel U. Thibault.
page last modified: 2016-09-19; loaded in 0.0013 seconds