![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Connecting to All Users Desktop Hi I have below code to change the icons of all shortcuts on All User Desktop. Problem is I am connecting to All Users' Desktop twice, once using Namespace and second using SpecialFolders. Is there a way to simplify code to connect to All Users Desktop only once? Sorry if it is dumb. I am very new to vbscript. Many Thanks Regards Set oFS = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") Const ALL_USERS_DESKTOP = &H19& Set objShellApp = CreateObject("Shell.Application") Set objFolder = objShellApp.Namespace(ALL_USERS_DESKTOP) strFolder = objShell.SpecialFolders("AllUsersDesktop") For Each objFile In oFS.GetFolder(strFolder).Files If Right(LCase(objFile.Name), 4) = LCase(".lnk") Or Right(LCase(objFile.Name), 4) = LCase(".url") Then Set objFolderItem = objFolder.ParseName(objFile.Name) Set oLink = objFolderItem.GetLink oLink.SetIconLocation "C:\Windows\System32\SHELL32.dll", 109 oLink.Save End If Next |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Connecting to All Users Desktop John, Actually, you're not really doing extra work per se, but if I understand you correctly, you want to make the code look cleaner somehow. It's still easiest to find the items by iterating through with the filesystemobject I believe, but you can get the path directly from the shell.application object, like this: strFolder = objFolder.Self.path As for dumb - you should see some of the things _I_ asked when I was first starting out. You know the drill - the only dumb question is the one you didn't ask. : ) "John" <info@xxxxxx> wrote in message news:O7JvH9xoJHA.3840@xxxxxx Quote: > Hi > > I have below code to change the icons of all shortcuts on All User > Desktop. Problem is I am connecting to All Users' Desktop twice, once > using Namespace and second using SpecialFolders. Is there a way to > simplify code to connect to All Users Desktop only once? > > Sorry if it is dumb. I am very new to vbscript. > > Many Thanks > > Regards > > > Set oFS = CreateObject("Scripting.FileSystemObject") > Set objShell = CreateObject("WScript.Shell") > > Const ALL_USERS_DESKTOP = &H19& > Set objShellApp = CreateObject("Shell.Application") > Set objFolder = objShellApp.Namespace(ALL_USERS_DESKTOP) > > strFolder = objShell.SpecialFolders("AllUsersDesktop") > For Each objFile In oFS.GetFolder(strFolder).Files > If Right(LCase(objFile.Name), 4) = LCase(".lnk") Or > Right(LCase(objFile.Name), 4) = LCase(".url") Then > Set objFolderItem = objFolder.ParseName(objFile.Name) > Set oLink = objFolderItem.GetLink > oLink.SetIconLocation "C:\Windows\System32\SHELL32.dll", 109 > > oLink.Save > End If > Next > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Connecting Laptop using XP to Desktop using Vista 64 Premium | Vista networking & sharing | |||
| Connecting laptop to desktop | Vista hardware & devices | |||
| Connecting Desktop to Laptop | Vista General | |||
| Connecting to Vista with RDP causes old desktop icons to appear | Vista General | |||
| remote desktop connecting???? | Vista networking & sharing | |||