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. #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
Hi, I have a windows 2003 server on my network(its actually a virtual machine running on windows server 2008), that I have enabled remote access...
Server General
Connecting Laptop using XP to Desktop using Vista 64 Premium
Is it possible using the same type of cable that I'd use to hook a router with a computer, (yellow cable) to directly connect my laptop to my...
Vista networking & sharing
Connecting laptop to desktop
Can I connect my laptop to my desktop computer? -- LasVegas
Vista hardware & devices
Connecting Desktop to Laptop
I run Vista Ultimate on my d/top and WXP on my laptop and connect the two for networking purposes with a simple crossover cable. On Network and...
Vista General
Remote Desktop unavailable on lan after connecting to wireless?
So I am trying to manage my system and a wireless router using a remote desktop connection only to find that when I try to connect to any wireless...
Vista General
Connecting to Vista with RDP causes old desktop icons to appear
I have two Vista machines, both using Vista Business. "Machine 1" had many large files on the desktop (iso files I downloaded, etc). I deleted...
Vista General
remote desktop connecting????
Connecting two home computers across the Internet is also possible. However, doing this typically requires detailed knowledge of the router...
Vista networking & sharing