Windows Vista Forums

Connecting to All Users Desktop

  1. #1


    John Guest

    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 SpecsSystem Spec

  2.   


  3. #2


    Alex K. Angelopoulos Guest

    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

    > 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 SpecsSystem Spec


Connecting to All Users Desktop
Similar Threads
Thread Forum
can only see local machine users when trying to add users allowed for remote desktop access Server General
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