Author: NetworkAdminKB.com
Created: 2008-03-13
Modified: 2010-11-21
Version: 1.3.6
The Change Shortcuts Utility (ChangeLNKS) can be used to do any of the following.
1) Create an HTML or CSV reports on all existing shortcuts
a. Specify the /r parameter on the command line
b. This can be done on local or remote servers
i. Local: /d=”C:\”
ii. Remote: /d=”\\computer1\C$”
c. Specify the following in the paths.txt file
i. :\;:\
ii. \\:\\
2) Create an HTML or CSV report on selective shortcuts by name, location, or the shortcut’s Target or Working folder.
a. Specify the /r parameter on the command line
b. By name: include a list of shortcut name to search for in the names.txt file
c. By location: specify the target location to search as the target folder using the /d switch
d. By Target/Working folder: specify the appropriate paths used to search the target and working folder setting of the shortcuts
3) Produce an HTML or CSV reports of all the scripts activity
a. By default CSV reports are created, use the /o parameter to make HTML reports.
b. CSV reports use the semicolon (;) as the separator.
4) Replace settings in the shortcut’s Target and Working folder
a. Configure the paths.txt file as needed to change the contents of the Target and Working folder strings.
b. You can change between UNC and drive letters and vice versa if needed.
c. You can search and replace any part of the Target or Working folder settings
i. Examples: drive letters, UNC server name, UNC share names, folder names, file names, file extensions, or any part of these settings.
5) Rename shortcut links to reflect new names.
a. Configure the names.txt file as needed to change the file name of the shortcut.
b. You can replace the whole file name or any part there of.
Requirements and Limitations
1) Permissions required
a. ChangeLNKS will not bypass NTFS security. The user running it should have full access to all folders.
b. In general, NTFS Modify permissions are required by the user running this program.
2) Speed
a. Remote connections (/d=\\server\d$) will be slow
b. Modifying shortcuts whose targets no longer exists will be slow
c. These are limitations of how shortcuts are implemented, not the program itself. By design when modifying a shortcut, the target path is verified when the shortcut is opened. I both of the above cases the path will not exist, and will require the OS to timeout searching for it.
3) VB6 Runtime may be required on Windows 2000 or earlier OS.
Syntax:
Author: NetworkAdminKB.com
Version: 1.3.6
Copyright (c) 2008-2010 NetworkAdminKB.com, All rights reserved.
Bug Report: bugs@networkadminkb.com
Purpose: Change shortcuts (lnk files) by search and replacing text.
No Arguments Given.
Syntax:
ChangeLNKs /d=[drive:\][path] [/p=lnkpaths] [/n=lnknames]
[/o=[=OutputPath] [/r]
Purpose: Change shortcuts (lnk files) by search and replacing the text as
specified in the input files.
/d=[drive:\]path Specify the Drive and/or path to the starting
folder that is to be checked.
/n=lnknames A text file of names to search and replace.
search;replace
/p=lnkpath A text file of paths to search and replace.
search;replace
Optional Parameters
/o[=OutputPath] Specify the path and/or filename to direct output to.
(A path must end with '\')
/r Report Only, do not modify lnk files
Exmamples:
ChangeLNKs /d=E:\ /n=names.txt /p=paths.txt
ChangeLNKs /d=Folder1 /n=names.txt /p=paths.txt /o=C:\
ChangeLNKs /d=E:\Folder1\Subfolder /n=names.txt /p=paths.txt /r
names.txt - replace any text in the lnk file name
Server1;Server3
Server2;Server3
paths.txt - in general, ordered specific to general
\\server1\share1;\\Server3\Share2
F:;\\Server3\Share2
\\Server1;\\Server3
F:;\\Server3
Example Output of ChangeLNKs
C:\>Changelnks /d="C:\Documents and Settings\All Users" /n=names.txt /p=paths.txt /o /r
Author: NetworkAdminKB.com
Version: 1.3.6
Copyright (c) 2008-2010 NetworkAdminKB.com, All rights reserved.
Bug Report: bugs@networkadminkb.com
Purpose: Change shortcuts (lnk files) by search and replacing text.
11/10/2010 4:39:45 PM: An error occurred while accessing folder C:\Documents and
Settings\All Users\Application Data\Symantec\SRTSP\SrtETmp
0x46 - Permission denied
Procedure: SearchFolderForLinks
Names.txt
Server1;Server3
Server2;Server3
Paths.txt
\\Server1\Shared;\\Server3\Shared
\\Server2\Shared;\\Server3\Shared
Logfile Date: 2010-11-10 16:39:37
Starting Folder: C:\Documents and Settings\All Users
|
Original Shortcut Name
|
New Shortcut Name
|
LNK Target Path
|
New LNK Target Path
|
Updated?
|
|
C:\Documents and Settings\All Users\Desktop\Server1 Project1.lnk
|
C:\Documents and Settings\All Users\Desktop\Server3 Project1.lnk
|
\\Server1\Shared\Projects\Project1.doc
|
\\Server3\Shared\Projects\Project1.doc
|
Report: Shortcut Name and Link
|
|
C:\Documents and Settings\All Users\Desktop\Server1 Project2.lnk
|
C:\Documents and Settings\All Users\Desktop\Server3 Project2.lnk
|
\\Server1\Shared\Projects\Project1.doc
|
\\Server3\Shared\Projects\Project2.doc
|
Report: Shortcut Name and Link
|
|
C:\Documents and Settings\All Users\Desktop\Server2 Project3.lnk
|
C:\Documents and Settings\All Users\Desktop\Server3 Project3.lnk
|
\\Server2\Shared\Projects\Project3.doc
|
\\Server3\Shared\Projects\Project3.doc
|
Report: Shortcut Name and Link
|
|
C:\Documents and Settings\All Users\Desktop\Server2 Project4.lnk
|
C:\Documents and Settings\All Users\Desktop\Server3 Project4.lnk
|
\\Server2\Shared\Projects\Project4.doc
|
\\Server3\Shared\Projects\Project4.doc
|
Report: Shortcut Name and Link
|
Using the names.txt (lnknames) and paths.txt (lnkpaths) options.
In general you should order the items in these files from specific to general. For example you should order items in the following order, paths to subfolder, then parent folders, then shares, then servers. A more specific example is shown below.
\\server1\share1\folder1\folder2\folder3;\\server2\share2\folder2\folder3\folder4
\\server1\share1\folder1\folder2;\\server2\share2\folder2\folder3
\\server1\share1\folder1\;\\server2\share2\folder2
\\server1\share1;\\server2\share2
\\server1;\\server2
The same process should be used for then names.txt file as well.
Using the default CSV Reporting
If the /o switch is omitted the default is to display to the screen the results in a CSV format. However, because the LNK file settings may contain commas as well, the format uses the semicolon (;) instead of CSV.
To capture output to a file use redirection (>) to a file name.
C:\>Changelnks /d="C:\Documents and Settings\All Users" /n=names.txt /p=paths.txt /r >c:\myreports\changelnks.txt
Download ChangeLNKs
Article ID: 264, Created On: 9/18/2011, Modified: 9/18/2011