獲取用戶目錄下所有快捷方式的url – Javascript教程_JS教程_技術文章 – 程式設計聯盟

 

Set WshShell = Wscript.CreateObject("Wscript.Shell")

 

Function TreeIt(sPath)

 

 Set oFso = CreateObject("Scripting.FileSystemObject")

 

 Set oFolder = oFso.GetFolder(sPath)

 

 Set oSubFolders = oFolder.Subfolders

 

 

 

 Set oFiles = oFolder.Files

 

 For Each oFile In oFiles

 

   If oFso.GetExtensionName(oFile) = "lnk" Or oFso.GetExtensionName(oFile) = "url" Then

 

  Set oMyShortcut = WshShell.CreateShortcut(oFile)

 

  wscript.echo oMyShortcut.targetpath

 

  End If

 

 Next

 

 

 

 For Each oSubFolder In oSubFolders

 

  TreeIt(oSubFolder.Path)'遞歸

 

 Next

 

 

 

 Set oFolder = Nothing

 

 Set oSubFolders = Nothing

 

 Set oFso = Nothing

 

End Function

 

 

 

TreeIt("C:\Documents and Settings")

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *