我想删除桌面文件夹中的所有快捷方式,并确保添加一组干净的shorcuts.
但是,我需要保持shorcuts映射驱动器.如果查看"属性"的"快捷方式"选项卡,可以看到此类型的快捷方式具有Target type"文件夹".
问题是,我找不到通过VBS访问目标类型的任何方法.我可以得到type(objFile.Type),但是它会Type of file在'General'选项卡上显示(在本例中为'Shortcut').
有没有人知道一种访问方式Target type?谢谢.
For Each objFile in objFolder.Files
' Check that the file 'Target type' is not 'File Folder'
If Not objFile.Type = "File Folder" Then
objFSO.DeleteFile(desktop_locations(i) & objFile.Name)
End If
Next
Run Code Online (Sandbox Code Playgroud)
您需要检查快捷方式的目标:
Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("WScript.Shell")
shortcut = "C:\path\to\some.lnk"
Set lnk = sh.CreateShortcut(shortcut)
If Not fso.FolderExists(lnk.TargetPath) Then
'target doesn't exist or is not a folder
fso.DeleteFile shortcut
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1769 次 |
| 最近记录: |