LN                              User Manual                              LN

NAME     Creates hard links and shell links and lists files with
                link information.

VERSION
        2.2 (2002.04.08) Copyright (C)2001, 2002, Frank P. Westlake.

SYNOPSIS
        [stdout | ] LN [options] [existing-file[s] | URL] [new-link[s]]
        [stdout | ] LN [/l|-l|--list] [Path, file, or wildcards]
        [stdout | ] LN [/x|-x|--index] [Path] file or file-index

LICENSE
        No sales for profit. Otherwise unlimited use and unlimited
        redistribution. 

DESCRIPTION
        OVERVIEW
        LN is a Windows NT executable file that runs in a console window
        and is designed to behave similar to the Linux version with the
        same name. LN creates both hard links and Windows shell links.
        Shell links behave similar to Linux symbolic links but they are not
        the same thing. LN's shell link ability is limited to Windows
        shortcuts (.LNK) and Internet shortcuts (.URL). LN will also list
        link information for a specified file, files in a specified
        directory, or a specified wildcard. LN can also search a specified
        directory, recursively if desired, for a file with a matching file
        index. This is useful in locating all file links that point to the
        same file. LN accepts a command line pipe and will append the
        information to the command line tail.

        HARD LINKS (NTFS only)
        A file exists once on a volume and normally has a single link, but
        multiple links can exist in any directory and under any name on
        that same volume. A hard link is an additional link to the file and
        any of the links can be used to open the file. If the file is
        modified and closed, those modifications will exist regardless of
        which link it is subsequently opened with. Simply described, a hard
        link is an additional name for a file. If one of the filenames is
        deleted the file will continue to exist and can be accessed via any
        of the remaining links. If a file is moved to the Recycle Bin it
        will continue to exist as an additional link until the file is
        deleted from the Recycle Bin. Hard links provide two great
        benefits: a file can be conveniently accessed from multiple working
        directories and an additional link can be maintained to avoid
        accidental deletion. It will not, however, prevent overwriting the
        file with another empty file or deletion of its contents with an
        editor. A hard link cannot exist for a directory.

        SHELL LINKS
        A shell link is an additional file that contains a reference to a
        resource and instructions for the use or presentation of that
        resource. Shell links are commonly called shortcuts, although
        shortcuts are only a subset of shell links. LN can read and write
        Windows shortcuts with the extension .LNK and Internet shortcuts
        with the extension .URL. Windows shortcuts (.LNK) can reference a
        file or directory on any local or shared volume (hard links must
        exist on the same volume). Shortcuts are typically created by
        dragging an icon to a new location with Windows Explorer. Internet
        shortcuts can reference a resource on an HTTP server or on the
        local computer by using the http:// and file:// prefixes
        respectively. Windows shortcuts are binary files and LN uses the
        COM interface to create them, but Internet shortcuts are text files
        written with the following format:

        [InternetShortcut]
        URL=[URL string]
        Modified=[Date value]
        Hotkey=[Hotkey value]
        WorkingDirectory=[Path string]
        ShowCommand=[Showcommand value]

        For example:

        [InternetShortcut]
        URL=http://www.linux.org/
        Modified=609EDF621E3DC1015C
        Hotkey=1601
        WorkingDirectory=C:\ht_docs
        ShowCommand=3

        FILE INDEX
        Every file has an index value that uniquely identifies it on a
        volume and each volume has a serial number that uniquely identifies
        it on the system. Together these values uniquely identify the file.
        The volume serial number is normally displayed with the output from
        the DIR command. The file index may change when the system is
        restarted or when the file is opened, but when opened, the
        identifier remains constant until the file is closed. The Windows
        API offers the GetFileInformationByHandle() function as the only
        means to retrieve a file index, but this function produces
        unreliable index values when used on a UNC path or on a network
        share path. In these two cases LN will succeed in creating links
        but will only list the number of links, filenames, and any
        requested shell link information. All file indexes will be zeroed.

        PARAMETERS
        command
                        Any of the parameters may be piped in.

        existing-file[s]
                        File, directory, or wild card pattern to link to. A
        directory can only be specified when creating shell links (this is
        a diversion from the behavior on a Linux system).

        URL
                        A Uniform Resource Locator for an Internet
        shortcut. URL's for use across a network or on a local HTTP server
        begin with "http://", those for use with the local file system
        begin with "file://".

        new-link[s]
                        New link, or links, to existing-file[s]. If
        existing-file[s] is a wild card pattern then new-link must be a
        directory to create the links in. If existing-file[s] is a single
        file then new-link may be a file or a directory. If it is a file
        then a link will be created with that name. If it is a directory
        then the new link will be created in the specified directory with
        same filename part as existing-file.

        OPTIONS
        User's choice of slash, hyphen, or double hyphen switches.

        /-
                        Disable hyphen switches so that they can be read as
        filenames. Slashes are not permitted in filenames but hyphens are.
        This option allows you to create links to files with names matching
        any of the options, such as "--backup".

        /a: -a: --arguments:
                        Command line arguments for shell links. If the
        string contains delimiters it must be enclosed in quotes (i.e. 
        /a:"my dir\my file" or "/a:my dir\my file"). If used in conjunction
        with the list switch, the command line arguments will be displayed.

        /b  -b  --backup
                        If the destination file exists it will be copied to
        a new file with the same name, except that a tilde (~) will be
        appended to the base name portion (i.e. basename.ext to
        basename~.ext). This option works only when force is specified.

        /c: -c: --comment:
                        A text string that is embedded in the shell link.

        /d: -d: --directory:
                        Working directory for shell links (see comments on
        arguments above).

        /e  -e  --expand
                        Shortcuts often use variables, such as %ComSpec%,
        in paths. This option will expand those environment variables in
        the output.

        /f  -f  --force
                        If destination file exists, overwrite it. Normally,
        if the new link already exists the link will fail.

        /i  -i  --interactive
                        Ask before overwriting an existing file.

        /k: -k: --key:
                        Virtual-key code value for shell link hot key (see
        comments on arguments above). Hot keys are not validated. To be
        certain that your hot key sequence is valid for shortcuts, try
        entering it in a shortcut dialog first. Format:
        /k:[flags:][hex|decimal|char], where flags may be any of
        SHIFT-CTRL-ALT-EXT. Examples for CTRL-ALT Z:
        /k:CTRL-ALT:Z, /k:1626, /k:0x065A, /k:CTRL-ALT:0x5A, /k:CTRL-ALT:90

        /l  -l  --list
                        List all specified files with their link
        information. The switches for arguments, directory, and key may
        also be used to provide more information.
        Output format: FILEINDEX #LINKS LINKNAME[ -> TARGETNAME]

        /n: -n: --icon:[#number:]path
                        Icon for a shell link. Replace 'path' with the path
        and filename of the file containing an icon. Icon 0 will be
        selected from the file unless 'number' is included, for example:
          LN /s file newlink.lnk /n:#1:C:\winnt\system32\SHELL32.dll


        /o[g]  -o[g]  --resolve[g]
                        Resolve the shell link. Uses the system's routine
        to locate a misplaced target file. Appending 'g' to the switch
        enables the system's GUI dialog.

        /p  -p  --fullpath
                        Replace relative paths with full paths in the
        output.

        /r  -r  --recurse
                        Include subdirectories in a file index search.

        /s  -s  --shell  --symbolic
                        Create a shell link. Default is to create a hard
        link.

        /v  -v  --verbose
                        Print successful actions in addition to failures.

        /w: -w: --window:
                        The initial state of the window. This option should
        be immediately followed by Min, Max, or Normal (i.e. /w:Max).

        /x  -x  --index
                        Find file links with the specified index or with
        the index of the specified file.
        Output format: FILEINDEX #LINKS LINKNAME[ -> TARGETNAME]

        /z  -z  --all
                        Applies the switches /a, /c, /d, /k, and /w for the
        list output.


EXAMPLES
        LN "%USERPROFILE%\budget.txt" "%USERPROFILE%\NoDelete\"
        LN "%USERPROFILE%\budget.txt" "%USERPROFILE%\NoDelete\budget01.txt"
        LN /x /r "%USERPROFILE%\" "%USERPROFILE%\budget.txt"
        LN /s C:\WINNT\Notepad.exe "C:\My Log\Log.lnk" /a:Log.txt
          "/d:C:\My Log"
        LN /o /v "%USERPROFILE%\budget.txt.lnk"

AUTHOR
        Frank P. Westlake Bugs@fpw.static.pe.net
        http://home.pe.net/~fpw/

LN                                                                       LN