Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Replacing shortcuts with target files

$
0
0
Hey everyone this is the very first thing I have ever done with vbs.

My mission was to replace all shortcut files in a folder with their targets then delete the shortcut, I have achieved this but I'm not too sure how well.

Can anyone give me any pointers on my code, I learned everything from the source code of the I love you virus so my code may be really out of date :P Thanks everyone!

main()
sub main()
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")

Set Shell = CreateObject("WScript.Shell")
dim DesktopPath
DesktopPath = "C:\Users\User\Desktop\"

dim f,f1,fc,ext
set f = filesys.GetFolder(DesktopPath)
set fc = f.Files
for each f1 in fc
ext=filesys.GetExtensionName(f1.Path)
if(ext="lnk") Then
Set Shortcut = Shell.CreateShortcut(f1.Path)
If filesys.FileExists(Shortcut.TargetPath) Then
filesys.CopyFile Shortcut.TargetPath, DesktopPath
filesys.DeleteFile(f1.Path)
end if
end if
next
end sub

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>