jukuhuku
Goto Top

Modify a vb script to change the targets in lnk files

greetings,

i`m using the following vb script over the "send as" menu to change the two targets inside lnk files (static drive letter to unc path). how can i modify the script to search lnk files in subfolders too? is there an easy way to modify the script for a recursive search in subfolders without changing the basement and the design of the script?

On Error Resume Next
set WshShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
set objArgs = WScript.Arguments
set fld = fso.GetFolder(objArgs(0))
set fc = fld.Files
For Each f1 in fc
If UCase(Right(f1.name, 3)) = "LNK" Then
Set sl = WshShell.CreateShortcut(f1.Path)
z = sl.TargetPath
z = Replace(z, "S:\", "\\server\data\")
sl.TargetPath = z
y = sl.WorkingDirectory
y = Replace(y, "S:\", "\\server\data\")
sl.WorkingDirectory = y
sl.Save
Username = WshShell.ExpandEnvironmentStrings("%USERNAME%")
x = sl.TargetPath
x = Replace(x, "P:\", "\\server\redirected\%username%\documents\personal\")
sl.TargetPath = x
w = sl.WorkingDirectory
w = Replace(w, "P:\", "\\server\redirected\" & createobject("wscript.shell").expandenvironmentstrings("%username%") & "\documents\personal\")
sl.WorkingDirectory = w
sl.Save
End If
Next
WScript.Echo "done!"

thanks for your help.

Content-Key: 348344

Url: https://administrator.de/contentid/348344

Printed on: April 26, 2024 at 16:04 o'clock

Mitglied: 133883
Solution 133883 Sep 06, 2017 updated at 11:04:00 (UTC)
Goto Top
Hi there,
our search gives you all answers face-wink, here is your code for searching subfolders for lnk files
Mehrere Verzeichnisse in einen Script angeben
A simple sub wich calls itsself for all folders and subfolders.

Regards
Mitglied: 133883
133883 Sep 08, 2017 updated at 12:52:50 (UTC)
Goto Top
Don't forget How can I mark a post as solved? please, thanks.