.vbs 对用户收藏夹列表进行排序

发布于 2024-10-31 19:48:52 字数 8518 浏览 0 评论 0原文

该脚本的总体目标: 发送给员工并向每台笔记本电脑添加一组收藏夹(Web 文件夹)。到目前为止,我已经编写(来源和改编)一个脚本来将所有文件夹添加到收藏夹中,但它们被插入到收藏夹列表的末尾。

我正在寻找一种按日期对收藏夹列表进行排序的方法,或者更好地将文件夹插入列表顶部,这样它就不会更改当前用户收藏夹的顺序。

这是我到目前为止所拥有的,链接不起作用,因为它们位于我们的内联网上

'Create Network Folder*******************************************  


Option Explicit  
MsgBox("Click OK to begin installing all of the Web Folders under My Network Places.")


Sub CreateNetworkFolder(siteURL, siteName)  

Dim iRes, jRes, MT, TT  
Dim SH, newPath  
Dim objFso, f, fs, g  

Dim bString  
Dim ltrIndex  
Dim nameLength, urlLength, urlCutoff  
Dim aFile  
Dim filesys

'ForWriting (2) is the attribute to be set when writing to a file.  
Const ForWriting = 2  

nameLength = Len(siteName)  
urlLength = Len(siteURL)  
'44 seems to be the length where we have to change a 00 to a 01.  
urlCutoff = 44  

Set objFso = CreateObject("Scripting.FileSystemObject")  

Set SH = WScript.CreateObject("WScript.Shell")  

'Create the folder under Favorites that will hold the target.lnk file  
newPath = SH.SpecialFolders("Favorites") & "\" & "BCKM" & "\"  

'Creating the housing folder for BCKM
Set filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(newPath) Then
   'msgbox "File esists"
  else
   'msgbox "file does not exist"
   objFso.CreateFolder(newPath) 
End If



'Create the webfolder for each section
newPath = SH.SpecialFolders("Favorites") & "\" & "BCKM" & "\" & siteName 
objFso.CreateFolder(newPath) 

'We ceate a Desktop.ini file  
Set fs = CreateObject("Scripting.FileSystemObject")  
aFile = newPath & "\Desktop.ini"  

Set f = fs.OpenTextFile( aFile, ForWriting, True )  

'Write the data lines that will make this a folder shortcut.  
f.WriteLine "[.ShellClassInfo]"  
f.WriteLine "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}"  
f.WriteLine "Flags=2"  
f.WriteLine "ConfirmFileOp=0" 



f.Close  

'We make Desktop.ini a system-hidden file by assigning it attribute of 6  
Set fs = CreateObject("Scripting.FileSystemObject")  
Set g = fs.GetFile(newPath & "\Desktop.ini")  
g.Attributes = 6  

'We make the folder read-only by assigning it 1.  
Set fs = CreateObject("Scripting.FileSystemObject")  
Set g = fs.GetFolder(newPath)  
g.Attributes = 1  

'This is where we construct the target.lnk file byte by byte. Most of  
'the lines are shown in 16 byte chunks,  
'mostly because that is the way I saw it in the Debug utility I was  
'using to inspect shortcut files.  

'Line 1, 16 bytes  
bString = Chr(&H4C) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H14) & Chr(&H02) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&HC0) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 2, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H46) & Chr(&H81) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 3, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 4., 16 bytes. 13th byte is significant.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 5. 13th byte is significant.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'When I was analyzing the next byte of shortcuts I created, I found  
'that it is set to various values,  
'and I have no idea what they are referring to. In desperation I tried  
'substituting some values.  
'00 caused a crash of Explorer. FF seeems to work fine for all.  
'If anyone can get back to me on what this byte is or why FF works,  
'please contact me.  
bString = bString & Chr(&HFF)  

'This byte is 00 if the URL is 44 characters or less, 01 if greater.  
If urlLength > urlCutoff Then  
bString = bString & Chr(&H01)  
Else  
bString = bString & Chr(&H00)  
End If  

bString = bString & Chr(&H14) & Chr(&H00)  

'Line 6, 16 bytes  
bString = bString & Chr(&H1F) & Chr(&H50) & Chr(&HE0) & Chr(&H4F) & Chr(&HD0) & Chr(&H20) & Chr(&HEA) & Chr(&H3A) & Chr(&H69) & Chr(&H10) & Chr(&HA2) & Chr(&HD8) & Chr(&H08) & Chr(&H00) & Chr(&H2B) & Chr(&H30)  

'Line 7, 16 bytes  
bString = bString & Chr(&H30) & Chr(&H9D) & Chr(&H14) & Chr(&H00) & Chr(&H2E) & Chr(&H00) & Chr(&H00) & Chr(&HDF) & Chr(&HEA) & Chr(&HBD) & Chr(&H65) & Chr(&HC2) & Chr(&HD0) & Chr(&H11) & Chr(&HBC) & Chr(&HED)  

'Line 8, 16 bytes  
bString = bString & Chr(&H00) & Chr(&HA0) & Chr(&HC9) & Chr(&H0A) & Chr(&HB5) & Chr(&H0F) & Chr(&HA4)  

'This byte is 00 if the URL is 44 characters or less, 01 if greater.  
If urlLength > urlCutoff Then  
bString = bString & Chr(&H01)  
Else  
bString = bString & Chr(&H00)  
End If  

bString = bString & Chr(&H4C) & Chr(&H50) & Chr(&H00) & Chr(&H01) & Chr(&H42) & Chr(&H57) & Chr(&H00) & Chr(&H00)  

'Line 9, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H10) & Chr(&H00)  

'Line 10, 2 bytes  
bString = bString & Chr(&H00) & Chr(&H00)  

'The next byte represents the length of the site name.  
bString = bString & Chr(nameLength)  

'Take the site name, and write each letter, preceeded by a "00"  
'character.  

For ltrIndex = 1 to nameLength  
bString = bString & Chr(&H00) & Mid(siteName, ltrIndex, 1)  
Next  

'Middle line, separates the Folder Name from the URL. 3 bytes.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'The next byte represents the length of the site URL.  
bString = bString & Chr(urlLength)  

'Take the site URL, and write each letter, preceeded by a "00"  
'character.  
For ltrIndex = 1 to urlLength  
bString = bString & Chr(&H00) & Mid(siteURL, ltrIndex, 1)  
Next  

'Last line, 13 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Let's create the target.lnk file.  
Set fs = CreateObject("Scripting.FileSystemObject")  
aFile = newPath & "\target.lnk"  
'aFile = newPath & "\vb.sss"  
Set f = fs.OpenTextFile(aFile, ForWriting, True)  
f.Write bString  
f.Close  

End Sub  

'This is where you specify the folders to add

CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685732/", "Clients" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685930/", "Workspaces" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685941/", "Practice Management" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685945/", "Tips" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.21.8015/", "Discussion Board" 


MsgBox("All Web Folders Added Succesfully. Please check Favorites to Confirm. Press OK") 

Overall Goal of this script:
To send out to employees and add a set of favourites(web folders) to each laptop. So far I have written(sourced and adapted) a script to add all the folder to the favourites but they are being instered at the end on the favourites list.

I am looking for a way to sort the list of favourites by date or even better to insert the folder at the top of the list so it wont change the order of the current users favourites.

This is what I have so far, the links wont work since they are on our intranet

'Create Network Folder*******************************************  


Option Explicit  
MsgBox("Click OK to begin installing all of the Web Folders under My Network Places.")


Sub CreateNetworkFolder(siteURL, siteName)  

Dim iRes, jRes, MT, TT  
Dim SH, newPath  
Dim objFso, f, fs, g  

Dim bString  
Dim ltrIndex  
Dim nameLength, urlLength, urlCutoff  
Dim aFile  
Dim filesys

'ForWriting (2) is the attribute to be set when writing to a file.  
Const ForWriting = 2  

nameLength = Len(siteName)  
urlLength = Len(siteURL)  
'44 seems to be the length where we have to change a 00 to a 01.  
urlCutoff = 44  

Set objFso = CreateObject("Scripting.FileSystemObject")  

Set SH = WScript.CreateObject("WScript.Shell")  

'Create the folder under Favorites that will hold the target.lnk file  
newPath = SH.SpecialFolders("Favorites") & "\" & "BCKM" & "\"  

'Creating the housing folder for BCKM
Set filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(newPath) Then
   'msgbox "File esists"
  else
   'msgbox "file does not exist"
   objFso.CreateFolder(newPath) 
End If



'Create the webfolder for each section
newPath = SH.SpecialFolders("Favorites") & "\" & "BCKM" & "\" & siteName 
objFso.CreateFolder(newPath) 

'We ceate a Desktop.ini file  
Set fs = CreateObject("Scripting.FileSystemObject")  
aFile = newPath & "\Desktop.ini"  

Set f = fs.OpenTextFile( aFile, ForWriting, True )  

'Write the data lines that will make this a folder shortcut.  
f.WriteLine "[.ShellClassInfo]"  
f.WriteLine "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}"  
f.WriteLine "Flags=2"  
f.WriteLine "ConfirmFileOp=0" 



f.Close  

'We make Desktop.ini a system-hidden file by assigning it attribute of 6  
Set fs = CreateObject("Scripting.FileSystemObject")  
Set g = fs.GetFile(newPath & "\Desktop.ini")  
g.Attributes = 6  

'We make the folder read-only by assigning it 1.  
Set fs = CreateObject("Scripting.FileSystemObject")  
Set g = fs.GetFolder(newPath)  
g.Attributes = 1  

'This is where we construct the target.lnk file byte by byte. Most of  
'the lines are shown in 16 byte chunks,  
'mostly because that is the way I saw it in the Debug utility I was  
'using to inspect shortcut files.  

'Line 1, 16 bytes  
bString = Chr(&H4C) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H14) & Chr(&H02) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&HC0) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 2, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H46) & Chr(&H81) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 3, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 4., 16 bytes. 13th byte is significant.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H01) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Line 5. 13th byte is significant.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'When I was analyzing the next byte of shortcuts I created, I found  
'that it is set to various values,  
'and I have no idea what they are referring to. In desperation I tried  
'substituting some values.  
'00 caused a crash of Explorer. FF seeems to work fine for all.  
'If anyone can get back to me on what this byte is or why FF works,  
'please contact me.  
bString = bString & Chr(&HFF)  

'This byte is 00 if the URL is 44 characters or less, 01 if greater.  
If urlLength > urlCutoff Then  
bString = bString & Chr(&H01)  
Else  
bString = bString & Chr(&H00)  
End If  

bString = bString & Chr(&H14) & Chr(&H00)  

'Line 6, 16 bytes  
bString = bString & Chr(&H1F) & Chr(&H50) & Chr(&HE0) & Chr(&H4F) & Chr(&HD0) & Chr(&H20) & Chr(&HEA) & Chr(&H3A) & Chr(&H69) & Chr(&H10) & Chr(&HA2) & Chr(&HD8) & Chr(&H08) & Chr(&H00) & Chr(&H2B) & Chr(&H30)  

'Line 7, 16 bytes  
bString = bString & Chr(&H30) & Chr(&H9D) & Chr(&H14) & Chr(&H00) & Chr(&H2E) & Chr(&H00) & Chr(&H00) & Chr(&HDF) & Chr(&HEA) & Chr(&HBD) & Chr(&H65) & Chr(&HC2) & Chr(&HD0) & Chr(&H11) & Chr(&HBC) & Chr(&HED)  

'Line 8, 16 bytes  
bString = bString & Chr(&H00) & Chr(&HA0) & Chr(&HC9) & Chr(&H0A) & Chr(&HB5) & Chr(&H0F) & Chr(&HA4)  

'This byte is 00 if the URL is 44 characters or less, 01 if greater.  
If urlLength > urlCutoff Then  
bString = bString & Chr(&H01)  
Else  
bString = bString & Chr(&H00)  
End If  

bString = bString & Chr(&H4C) & Chr(&H50) & Chr(&H00) & Chr(&H01) & Chr(&H42) & Chr(&H57) & Chr(&H00) & Chr(&H00)  

'Line 9, 16 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H10) & Chr(&H00)  

'Line 10, 2 bytes  
bString = bString & Chr(&H00) & Chr(&H00)  

'The next byte represents the length of the site name.  
bString = bString & Chr(nameLength)  

'Take the site name, and write each letter, preceeded by a "00"  
'character.  

For ltrIndex = 1 to nameLength  
bString = bString & Chr(&H00) & Mid(siteName, ltrIndex, 1)  
Next  

'Middle line, separates the Folder Name from the URL. 3 bytes.  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'The next byte represents the length of the site URL.  
bString = bString & Chr(urlLength)  

'Take the site URL, and write each letter, preceeded by a "00"  
'character.  
For ltrIndex = 1 to urlLength  
bString = bString & Chr(&H00) & Mid(siteURL, ltrIndex, 1)  
Next  

'Last line, 13 bytes  
bString = bString & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00) & Chr(&H00)  

'Let's create the target.lnk file.  
Set fs = CreateObject("Scripting.FileSystemObject")  
aFile = newPath & "\target.lnk"  
'aFile = newPath & "\vb.sss"  
Set f = fs.OpenTextFile(aFile, ForWriting, True)  
f.Write bString  
f.Close  

End Sub  

'This is where you specify the folders to add

CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685732/", "Clients" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685930/", "Workspaces" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685941/", "Practice Management" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.11.685945/", "Tips" 
CreateNetworkFolder "http://collaboration.au.xxx.com/dav/1.21.8015/", "Discussion Board" 


MsgBox("All Web Folders Added Succesfully. Please check Favorites to Confirm. Press OK") 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风追烟花雨 2024-11-07 19:48:52

为了跟进 Helen 的回答,注册表项中的“未记录数据”是相对 PCUITEMID_CHILD 的二进制形式(请参阅 MSDN) - 相对于磁盘上存储 .lnk 文件的文件夹。这就需要使用可以访问COM接口的语言,比如C++。

注册表项具有本文中记录的标头 - 然而,记录只是记录长度 (DWORD)、“顺序”值 (DWORD) 和 PCUITEMID_CHILD 数据。

typedef struct _FAV_ORDERED_HEADER_
{
    DWORD dwFormatValue;    // Typically 8 for known Windows versions that use this
    DWORD dwSubFormatValue; // Typically 2 for known Windows that use this
    DWORD dwTotalDataLen;   // Total bytes in all data
    DWORD dwReserved;       // No known use
    DWORD dwNumRecords;     // Number of records
} FAV_ORDERED_HEADER;

typedef struct _FAV_ORDERED_RECORD_
{
    DWORD dwLenRecord;       // Length of each record (skip this bytes to get next record)
    DWORD dwOrderValue;      // Negative if not ordered (add to end), positive if on list first
    ITEMIDLIST pidlLinkData; // PIDL data for the individiual link - need to use a PIDL compare to be able to compare to actual .lnk file links.
} FAV_ORDERED_RECORD;
  1. 首先使用 SHGetFolderLocation(NULL,CSIDL_FAVORITES,NULL,NULL,&ppidlFavorites) 获取收藏夹文件夹的 PIDLIST_ABSOLUTE。

  2. 通过 SHGetDesktopFolder() 获取桌面 IShellFolder 接口指针

  3. 桌面 IShellFolder 接口指针

    使用 IShellFolder 实例通过 IShellFolder::BindToObject(ppidlFavorites,NULL, IID_IShellFolder, &pFavoritesShellFolder)

  4. 通过调用 IShellFolder::GetDisplayNameOf( ) 将数据放入 pidl 参数中 - 并为要获取的字符串设置 SHGDNF 参数 - 显示名称、URL 等通常通过此方法获取。

这适用于 Windows 7/8 shell 链接中的“收藏夹”。但是,它需要使用 IKnownFolderManager::GetFolder(FOLDERID_Links,&pLinksKnFolder) 来获取 IKnownFolder,以便最终检索所需的 IShellFolder - 正确获取其 PIDLIST_ABSOLUTE。它的注册表项(用于链接排序)是:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\CommonPlaces

To follow up on Helen's answer, the "undocumented data" in the registry key are a binary form of the relative PCUITEMID_CHILD (See MSDN) - relative to the folder where the .lnk files are stored on disk. This requires using a language that can access COM interfaces, such as C++.

The registry key has the header as documented in the article - however, the records are simply the length of record (DWORD), the 'order' value (DWORD) and the PCUITEMID_CHILD data.

typedef struct _FAV_ORDERED_HEADER_
{
    DWORD dwFormatValue;    // Typically 8 for known Windows versions that use this
    DWORD dwSubFormatValue; // Typically 2 for known Windows that use this
    DWORD dwTotalDataLen;   // Total bytes in all data
    DWORD dwReserved;       // No known use
    DWORD dwNumRecords;     // Number of records
} FAV_ORDERED_HEADER;

typedef struct _FAV_ORDERED_RECORD_
{
    DWORD dwLenRecord;       // Length of each record (skip this bytes to get next record)
    DWORD dwOrderValue;      // Negative if not ordered (add to end), positive if on list first
    ITEMIDLIST pidlLinkData; // PIDL data for the individiual link - need to use a PIDL compare to be able to compare to actual .lnk file links.
} FAV_ORDERED_RECORD;
  1. First use SHGetFolderLocation(NULL,CSIDL_FAVORITES,NULL,NULL,&ppidlFavorites) to get the PIDLIST_ABSOLUTE of the Favorites folder.

  2. Get the desktop IShellFolder interface pointer via SHGetDesktopFolder()

  3. Use the IShellFolder instance to get to the Favorites IShellFolder via IShellFolder::BindToObject(ppidlFavorites,NULL, IID_IShellFolder, &pFavoritesShellFolder)

  4. Use the pFavoritesShellFolder with calls to IShellFolder::GetDisplayNameOf() with the data into the pidl parameter - and set the SHGDNF parameters for the string(s) to get - the display name, URL, etc. are typically obtained through this method.

This applies to the Windows 7/8 'Favorites' in the shell links. However, it requires the use of the IKnownFolderManager::GetFolder(FOLDERID_Links,&pLinksKnFolder) to get the IKnownFolder that will allow the eventual retrieval of the required IShellFolder - to properly get it's PIDLIST_ABSOLUTE. It's registry key (for link ordering) is:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Modules\CommonPlaces
将军与妓 2024-11-07 19:48:52

首先,为什么要以如此奇怪的方式创建快捷方式?通过调用 WshShell.CreateShortcut 可以更轻松地完成此操作 并设置生成的 WshShortcut 的属性 对象。

现在回答你的排序问题。有两个注册表项可管理收藏夹的状态:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites — 对应于 Internet Explorer 中显示的收藏夹。
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites — 对应于 Windows“开始”菜单中显示的收藏夹 >收藏夹。

收藏夹的排序顺序存储在这些键的 DWORD Order 值中。对于收藏夹中的每个文件夹,都有相应的子项,该子项也具有 Order 值。 Order 值的内部结构未记录,但本文 提供一些分析和解释。

因此,要更改排序顺序,您可以尝试从脚本中修改此值,例如使用 WMI StdRegProv.GetDWORDValueStdRegProv.SetDWORDValue 方法。不过,我想这会相当棘手。

请注意,从注册表中删除上述这些项应该按字母顺序对收藏夹进行排序(如果可以选择)。

First of all, why do you create shortcuts in such a bizarre way? This can be done a lot easier by calling WshShell.CreateShortcut and setting the properties of the resulting WshShortcut object.

Now to your sorting question. There're two registry keys that manage the state of Favorites:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites — corresponds to favorites displayed in Internet Explorer.
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites — corresponds to favorites displayed in Windows Start menu > Favorites.

The sort order of favorites is stored in the DWORD Order value of these keys. For each folder in Favorites there's the corresponding subkey that also has the Order value. The internal structure of the Order value is undocumented, but this article provides some analysis and explanation.

So, to change the sort order you could try modifying this value from your script, for example, using the WMI StdRegProv.GetDWORDValue and StdRegProv.SetDWORDValue methods. However, I guess it'd be rather tricky.

Note that deleting these abovementioned keys from the registry should sort Favorites in alphabetical order, if that's an option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文