Last active
August 29, 2015 14:02
-
-
Save MartinP7r/fc1169c8a7d7df1f5c87 to your computer and use it in GitHub Desktop.
creates shortcuts in ShortcutFolder for all Application files (*.exe) in all level-1 subfolders of the specified target folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'+-------------------------------------+ | |
'| @author: Martin Pfundmair | | |
'| @version: 1.0 | | |
'| @date: 2014-05-31 | | |
'| | | |
'| $cript: | | |
'| creates shortcuts in ShortcutFolder | | |
'| for all Application files (*.exe) | | |
'| in all level-1 subfolders of the | | |
'| specified target folders | | |
'+-------------------------------------+ | |
Option Explicit | |
Dim FSO: Set FSO = CreateObject("Scripting.FileSystemObject") | |
Dim WSO: Set WSO = CreateObject("Wscript.Shell") | |
Dim ShortcutFolder | |
'' Create Shortcuts in the following folder | |
ShortcutFolder = "C:\DropBox\PortableApps\!PortableApps Shortcuts" | |
' Delete all previous Shortcuts | |
DeleteShortcuts ShortcutFolder | |
'' Set Targetfolder here!!! | |
UpdateShortcuts "C:\DropBox\PortableApps\" | |
UpdateShortcuts "C:\DropBox\Programme\" | |
'' needs FSO | |
Sub UpdateShortcuts(dir) | |
Dim TargetFolder, SubFolders, SubFiles, SubFolder, item | |
Set TargetFolder = FSO.GetFolder(dir) | |
Set SubFolders = TargetFolder.SubFolders | |
For Each SubFolder In SubFolders | |
Set SubFiles = SubFolder.Files | |
For Each item In SubFiles | |
If item.type = "Application" Then | |
CreateShortcut item.name, SubFolder, ShortcutFolder | |
End If | |
Next | |
Next | |
End Sub | |
'' needs WSO | |
Sub CreateShortcut(app, sourceFolder, targetFolder) | |
Dim shortCut, targetFile | |
targetFile = Replace(app, ".exe", ".lnk") | |
targetFile = Replace(targetFile, "Portable", "") | |
Set shortCut = WSO.CreateShortcut(targetFolder&"\"&targetFile) | |
shortCut.TargetPath = sourceFolder&"\"&app | |
shortCut.Save | |
End Sub | |
'' needs FSO | |
Sub DeleteShortcuts(targetFolder) | |
Dim objFolder, objFile | |
Set objFolder = fso.GetFolder(targetFolder) | |
For Each objFile in objFolder.Files | |
If objFile.type = "Shortcut" Then | |
objFile.Delete True | |
End If | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: exclude exe files that are not launching the associated application. e.g. uninstaller, updater, etc.
possibly by regex or pattern from the folder name? or writing cases?
or: search/use information in portableapps files.