如何在用户桌面上创建计算机快捷方式

时间:2016-05-11 19:10:14

标签: windows vbscript shortcut wsh special-folders

我正在制作一个VBScript,用于在桌面上显示“计算机”图标。我已经能够使用以下代码为IE做一个,但是由于计算机是一个“特殊文件夹”,似乎没有实际位置我不能使用相同的方法。有人会知道如何通过VBScript启用它吗?

IE快捷键代码:

Set objShell = WScript.CreateObject("WScript.Shell")
 'Create Shortcut for IE on desktop
 allUsersDesktop = objShell.SpecialFolders("AllUsersDesktop")
 usersDesktop = objShell.SpecialFolders("Desktop")
 Set objShortCut = objShell.CreateShortcut(usersDesktop & "\Internet Explorer.lnk")
 objShortCut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
 objShortCut.Description = "Open Internet Explorer"
 objShortCut.Save

3 个答案:

答案 0 :(得分:4)

我的电脑CLSID为var xAxis = d3.svg.axis() .scale(xScale) .tickValues(xScale.domain().filter(function(d, i) { return !(i % 2); })) .orient("bottom"); ,因此代码应为:

::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

此外,您可以将以下shell命令用作With CreateObject("WScript.Shell") With .CreateShortcut(.SpecialFolders("Desktop") & "\My Computer.lnk") .TargetPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" .Description = "Open My Computer" .Save End With End With 值:

.TargetPath

电子。 G。 shell:AccountPictures shell:AddNewProgramsFolder shell:Administrative Tools shell:AppData shell:Application Shortcuts shell:AppsFolder shell:AppUpdatesFolder shell:Cache shell:CD Burning shell:ChangeRemoveProgramsFolder shell:Common Administrative Tools shell:Common AppData shell:Common Desktop shell:Common Documents shell:Common Programs shell:Common Start Menu shell:Common Startup shell:Common Templates shell:CommonDownloads shell:CommonMusic shell:CommonPictures shell:CommonRingtones shell:CommonVideo shell:ConflictFolder shell:ConnectionsFolder shell:Contacts shell:ControlPanelFolder shell:Cookies shell:Cookies\Low shell:CredentialManager shell:CryptoKeys shell:CSCFolder shell:Default Gadgets shell:Desktop shell:Device Metadata Store shell:DocumentsLibrary shell:Downloads shell:DpapiKeys shell:Favorites shell:Fonts shell:Gadgets shell:Games shell:GameTasks shell:History shell:HomeGroupCurrentUserFolder shell:HomeGroupFolder shell:ImplicitAppShortcuts shell:InternetFolder shell:Libraries shell:Links shell:Local AppData shell:LocalAppDataLow shell:LocalizedResourcesDir shell:MAPIFolder shell:MusicLibrary shell:My Music shell:My Pictures shell:My Pictures shell:My Video shell:MyComputerFolder shell:NetHood shell:NetworkPlacesFolder shell:OEM Links shell:Original Images shell:Personal shell:PhotoAlbums shell:PicturesLibrary shell:Playlists shell:PrintersFolder shell:PrintHood shell:Profile shell:ProgramFiles shell:ProgramFilesCommon shell:ProgramFilesCommonX64 shell:ProgramFilesCommonX86 shell:ProgramFilesX64 shell:ProgramFilesX86 shell:Programs shell:Public shell:PublicAccountPictures shell:PublicGameTasks shell:PublicLibraries shell:Quick Launch shell:Recent shell:RecordedTVLibrary shell:RecycleBinFolder shell:ResourceDir shell:Ringtones shell:Roamed Tile Images shell:Roaming Tiles shell:SampleMusic shell:SamplePictures shell:SampleVideos shell:SavedGames shell:Screenshots shell:Searches shell:SearchHomeFolder shell:SendTo shell:Start Menu shell:Startup shell:SyncCenterFolder shell:SyncResultsFolder shell:SyncSetupFolder shell:System shell:SystemCertificates shell:SystemX86 shell:Templates shell:User Pinned shell:UserProfiles shell:UserProgramFiles shell:UserProgramFilesCommon shell:UsersFilesFolder shell:UsersLibrariesFolder shell:VideosLibrary shell:Windows shell:::{00C6D95F-329C-409A-81D7-C46C66EA7F33} - Default Location shell:::{00F2886F-CD64-4FC9-8EC5-30EF6CDBE8C3} - Scanners and Cameras shell:::{0142E4D0-FB7A-11DC-BA4A-000FFE7AB428} - Biometric Devices shell:::{025A5937-A6BE-4686-A844-36FE4BEC8B6D} - Power Options shell:::{031E4825-7B94-4DC3-B131-E946B44C8DD5} - Libraries shell:::{05D7B0F4-2121-4EFF-BF6B-ED3F69B894D9} - Notification Area Icons shell:::{05D7B0F4-2121-4EFF-BF6B-ED3F69B894D9}\SystemIcons - System Icons shell:::{0907616E-F5E6-48D8-9D61-A91C3D28106D} - Hyper-V Remote File Browsing shell:::{0BBCA823-E77D-419E-9A44-5ADEC2C8EEB0} - NVIDIA Control Panel (if installed) shell:::{0DF44EAA-FF21-4412-828E-260A8728E7F1} - Taskbar and Start Menu shell:::{1206F5F1-0569-412C-8FEC-3204630DFB70} - Credential Manager shell:::{15EAE92E-F17A-4431-9F28-805E482DAFD4} - Get Programs shell:::{17CD9488-1228-4B2F-88CE-4298E93E0966} - Default Programs shell:::{1CF1260C-4DD0-4EBB-811F-33C572699FDE} - Music folder shell:::{1D2680C9-0E2A-469D-B787-065558BC7D43} - Fusion Cache shell:::{1F3427C8-5C10-4210-AA03-2EE45287D668} - User Pinned shell:::{1FA9085F-25A2-489B-85D4-86326EEDCD87} - Manage Wireless networks shell:::{208D2C60-3AEA-1069-A2D7-08002B30309D} - Network shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D} - Computer shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{374DE290-123F-4565-9164-39C4925E467B} - Downloads folder shell:::{21EC2020-3AEA-1069-A2DD-08002B30309D} - All Control Panel Items shell:::{2227A280-3AEA-1069-A2DE-08002B30309D} - Printers shell:::{22877A6D-37A1-461A-91B0-DBDA5AAEBC99} - Recent Places shell:::{241D7C96-F8BF-4F85-B01F-E2B043341A4B} - Remote Desktop Connection shell:::{2559A1F0-21D7-11D4-BDAF-00C04F60B9F0} - Search shell:::{2559A1F1-21D7-11D4-BDAF-00C04F60B9F0} - Windows Help and Support shell:::{2559A1F3-21D7-11D4-BDAF-00C04F60B9F0} - Run shell:::{2559A1F5-21D7-11D4-BDAF-00C04F60B9F0} - E-mail (default program) shell:::{2559A1F7-21D7-11D4-BDAF-00C04F60B9F0} - Set Program access and Windows defaults shell:::{2559A1F8-21D7-11D4-BDAF-00C04F60B9F0} - Search Apps shell:::{26EE0668-A00A-44D7-9371-BEB064C98683} - Control Panel (Category) shell:::{28803F59-3A75-4058-995F-4EE5503B023C} - Bluetooth Devices shell:::{289AF617-1CC3-42A6-926C-E6A863F0E3BA} - Media Servers shell:::{2965E715-EB66-4719-B53F-1672673BBEFA} - Results Folder shell:::{2E9E59C0-B437-4981-A647-9C34B9B90891} - Sync Setup Folder shell:::{3080F90D-D7AD-11D9-BD98-0000947B0257} - Desktop shell:::{3080F90E-D7AD-11D9-BD98-0000947B0257} - Win+Tab shell:::{323CA680-C24D-4099-B94D-446DD2D7249E} - Favorites shell:::{35786D3C-B075-49B9-88DD-029876E11C01} - Portable Devices shell:::{36EEF7DB-88AD-4E81-AD49-0E313F0C35F8} - Windows Update shell:::{37EFD44D-EF8D-41B1-940D-96973A50E9E0} - Desktop Gadgets shell:::{38A98528-6CBF-4CA9-8DC0-B1E1D10F7B1B} - Network Connections in Notification area shell:::{3ADD1653-EB32-4CB0-BBD7-DFA0ABB5ACCA} - Pictures folder shell:::{3F6BC534-DFA1-4AB4-AE54-EF25A74E0107} - System Restore shell:::{4026492F-2F69-46B8-B9BF-5654FC07E423} - Windows Firewall shell:::{40419485-C444-4567-851A-2DD7BFA1684D} - Phone and Modem shell:::{4234D49B-0245-4DF3-B780-3893943456E1} - Applications shell:::{4336A54D-038B-4685-AB02-99BB52D3FB8B} - Public shell:::{437FF9C0-A07F-4FA0-AF80-84B6C6440A16} - Command Folder shell:::{450D8FBA-AD25-11D0-98A8-0800361B1103} - My Documents shell:::{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} - Control Panel shell:::{58E3C745-D971-4081-9034-86E34B30836A} - Speech Recognition shell:::{59031A47-3F72-44A7-89C5-5595FE6B30EE} - User Folder shell:::{5EA4F148-308C-46D7-98A9-49041B1DD468} - Windows Mobility Center shell:::{60632754-C523-4B62-B45C-4172DA012619} - User Accounts shell:::{62D8ED13-C9D0-4CE8-A914-47DD628FB1B0} - Region and Language shell:::{645FF040-5081-101B-9F08-00AA002F954E} - Recycle Bin shell:::{67718415-C450-4F3C-BF8A-B487642DC39B} - Windows Features shell:::{6785BFAC-9D2D-4BE5-B7E2-59937E8FB80A} - HomeGroup folder shell:::{67CA7650-96E6-4FDD-BB43-A8E774F73A57} - HomeGroup shell:::{6C8EEC18-8D75-41B2-A177-8831D59D2D50} - Mouse Properties shell:::{6DFD7C5C-2451-11D3-A299-00C04F8EF6AF} - Folder Options shell:::{7007ACC7-3202-11D1-AAD2-00805FC1270E} - Network Connections shell:::{725BE8F7-668E-4C7B-8F90-46BDB0936430} - Keyboard Properties shell:::{74246BFC-4C96-11D0-ABEF-0020AF6B0B7A} - Device Manager shell:::{78F3955E-3B90-4184-BD14-5397C15F1EFC} - Performance Information and Tools (WEI) shell:::{7A9D77BD-5403-11D2-8785-2E0420524153} - Advanced User Accounts (netplwiz) shell:::{7B81BE6A-CE2B-4676-A29E-EB907A5126C5} - Programs and Features shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E} - Tablet PC Settings shell:::{85BBD920-42AO-1069-A2E4-08002B30309D} - Briefcase shell:::{863AA9FD-42DF-457B-8E4D-0DE1B8015C60} - Printers shell:::{871C5380-42A0-1069-A2EA-08002B30309D} - Internet Explorer shell:::{87D66A43-7B11-4A28-9811-C86EE395ACF7} - Indexing Options shell:::{8E0C279D-0BD1-43C3-9EBD-31C3DC5B8A77} - Windows To Go shell:::{8E74D236-7F35-4720-B138-1FED0B85EA75} - SkyDrive folder (Windows 8.1) shell:::{8E908FC9-BECC-40F6-915B-F4CA0E70D03D} - Network and Sharing Center shell:::{93412589-74D4-4E4E-AD0E-E0CB621440FD} - Font settings shell:::{9343812E-1C37-4A49-A12E-4B2D810D956B} - Search Results shell:::{96AE8D84-A250-4520-95A5-A47A7E3C548B} - Parental Controls shell:::{992CFFA0-F557-101A-88EC-00DD010CCC48} - Network Connections shell:::{9C60DE1E-E5FC-40F4-A487-460851A8D915} - AutoPlay shell:::{9C73F5E5-7AE7-4E32-A8E8-8D23B85255BF} - Sync Center shell:::{9FE63AFD-59CF-4419-9775-ABCC3849F861} - Recovery shell:::{A0275511-0E86-4ECA-97C2-ECD8F1221D08} - Infared shell:::{A0953C92-50DC-43BF-BE83-3742FED03C9C} - Videos folder shell:::{A304259D-52B8-4526-8B1A-A1D6CECC8243} - iSCSI Initiator Properties shell:::{A3DD4F92-658A-410F-84FD-6FBBBEF2FFFE} - Internet Properties shell:::{A6482830-08EB-41E2-84C1-73920C2BADB9} - Removable Storage Devices shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A} - Devices and Printers shell:::{A8CDFF1C-4878-43BE-B5FD-F8091C1C60D0} - Documents folder shell:::{AFDB1F70-2A4C-11D2-9039-00C04F8EEB3E} - Offline Files Folder shell:::{B155BDF8-02F0-451E-9A26-AE317CFD7779} - delegate folder that appears in Computer shell:::{B2C761C6-29BC-4F19-9251-E6195265BAF1} - Color Management shell:::{B4BFCC3A-DB2C-424C-B029-7FE99A87C641} - Desktop folder shell:::{B4FB3F98-C1EA-428D-A78A-D1F5659CBA93} - HomeGroup shell:::{B98A2BEA-7D42-4558-8BD1-832F41BAC6FD} - Windows 7 File Recovery shell:::{BB06C0E4-D293-4F75-8A90-CB05B6477EEE} - System shell:::{BB64F8A7-BEE7-4E1A-AB8D-7D8273F7FDB6} - Action Center shell:::{BD84B380-8CA2-1069-AB1D-08000948534} - Fonts shell:::{BE122A0E-4503-11DA-8BDE-F66BAD1E3F3A} - Add Features shell:::{BF782CC9-5A52-4A17-806C-2A894FFEEAC5} - Language Settings shell:::{C555438B-3C23-4769-A71F-B6D3D9B6053A} - Display (size of text) shell:::{C58C4893-3BE0-4B45-ABB5-A63E4B8C8651} - Troubleshooting shell:::{D17D1D6D-CC3F-4815-8FE3-607E7D5D10B3} - Text to Speech shell:::{D20EA4E1-3957-11D2-A40B-0C5020524153} - Administrative Tools shell:::{D24F75AA-4F2B-4D07-A3C4-469B3D9030C4} - Offline Files shell:::{D34A6CA6-62C2-4C34-8A7C-14709C1AD938} - Common Places FS Folder shell:::{D4480A50-BA28-11D1-8E75-00C04FA31A86} - Add Network Location shell:::{D450A8A1-9568-45C7-9C0E-B4F9FB4537BD} - Installed Updates shell:::{D555645E-D4F8-4C29-A827-D93C859C4F2A} - Ease of Access Center shell:::{D8559EB9-20C0-410E-BEDA-7ED416AECC2A} - Windows Defender shell:::{D9EF8727-CAC2-4E60-809E-86F80A666C91} - BitLocker Drive Encryption shell:::{E2E7934B-DCE5-43C4-9576-7FE4F75E7480} - Date and Time shell:::{E44E5D18-0652-4508-A4E2-8A090067BCB0} - Default Programs shell:::{E95A4861-D57A-4BE1-AD0F-35267E261739} - Windows SideShow (Windows 8 only) shell:::{E9950154-C418-419E-A90A-20C5287AE24B} - Location and Other Sensors shell:::{ECDB0924-4208-451E-8EE0-373C0956DE16} - Work Folders (Windows 8.1) shell:::{ED228FDF-9EA8-4870-83B1-96B02CFE0D52} - Games shell:::{ED50FC29-B964-48A9-AFB3-15EBB9B97F36} - printhood delegate folder shell:::{ED7BA470-8E54-465E-825C-99712043E01C} - All Tasks shell:::{ED834ED6-4B5A-4BFE-8F11-A626DCB6A921} - Personalization shell:::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C} - Network shell:::{F2DDFC82-8F12-4CDD-B7DC-D4FE1425AA4D} - Sound shell:::{F6B6E965-E9B2-444B-9286-10C9152EDBC5} - File History shell:::{F82DF8F7-8B9F-442E-A48C-818EA735FF9B} - Pen and Touch shell:::{F8C2AB3B-17BC-41DA-9758-339D7DBF2D88} - Previous Versions Results Folder shell:::{F90C627B-7280-45DB-BC26-CCE7BDD620A4} - Control Panel (All Settings) shell:::{F942C606-0914-47AB-BE56-1321B8035096} - Storage Spaces

注意,您只需在资源管理器窗口中输入shell命令作为测试它们的路径。

<强>更新

以下VBScript代码有助于测试某些CLSIDS:在桌面上的.TargetPath = "shell:::{1FA9085F-25A2-489B-85D4-86326EEDCD87}"文件夹中创建了快捷方式,还创建了文件夹对象,然后将报告保存并打开为\ShortcutTest文件。

.htm

答案 1 :(得分:1)

这应该可以解决问题:

Option Explicit
Const MY_COMPUTER = &H11
Dim ws, Desktop, Link, ObjF, ObjFItem, Shell
Set ws = CreateObject("Wscript.Shell")
Set Shell = CreateObject("Shell.Application")
Set ObjF = Shell.Namespace(MY_COMPUTER)
Desktop = ws.SpecialFolders("Desktop")
Set Link = ws.CreateShortcut(Desktop & "\My Computer.lnk")
Set ObjFItem = ObjF.Self
Link.TargetPath = ObjFItem.Path
Link.WindowStyle = 1
Link.IconLocation = "Shell32.dll, 15"
Link.Description = "Shortcut To My Computer"
Link.WorkingDirectory = Desktop
Link.Save

答案 2 :(得分:1)

TL; DR

虽然这不是创建快捷方式的标准方法,但在这种情况下,它可能是您的最佳选择。

创建&#34;计算机&#34;的快捷方式与GUI shell交互式。要部署快捷方式:使用脚本复制该文件。

说明

Windows快捷方式(.lnk)是Windows的无数未记录功能之一。虽然我找不到文件格式的任何描述,但它并不是非常复杂。您以交互方式创建/编辑它们时可以设置的字段存在于文件中(使用UCS-16LE或某些类似的编码)。

通常,您可以在编辑快捷方式时查看Windows用于快捷方式目标的内容。当您查看其中一个特殊快捷方式时,Windows将隐藏CLSID(或实际上的任何内容) - 一个众所周知的引用Windows Special™的GUID。对于&#34;计算机,&#34;该标识符为{{1}},我怀疑(!!)从计算机移动到计算机时它根本没有变化。

这里是我刚刚创建的快捷方式的十六进制转储。 hex dump of shortcut to computer 我没有看到任何特定于安装的引用。

如果快捷方式取决于环境变量或其他特定于计算机的详细信息,那么仅复制.lnk文件将是一个糟糕的主意。但是,因为使用The Right Way™并不容易,所以复制.lnk文件应该很容易且(合理地)健壮。