jukuhuku

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.
Auf Facebook teilen
Auf X (Twitter) teilen
Auf Reddit teilen
Auf Linkedin teilen

Content-ID: 348344

Url: https://administrator.de/forum/modify-a-vb-script-to-change-the-targets-in-lnk-files-348344.html

Ausgedruckt am: 04.05.2025 um 09:05 Uhr

133883
Lösung 133883 06.09.2017 aktualisiert um 13:04:00 Uhr
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
133883
133883 08.09.2017 aktualisiert um 14:52:50 Uhr
Goto Top