Desktop Icon Scripts for objShortcut.TargetPath

Home Forums Scripting Windows Script Host Desktop Icon Scripts for objShortcut.TargetPath

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    bobsha
    Member
    #160161

    Thanks in advance and please dont mind the noobness

    I need to search many PCs (With VBS if possible) but I will run this locally at login script or GPO

    * This PC can be Win7x32, Win7x64, XPx32, and XPx64

    I need to look at any profile on the box and look at the objShortcut.TargetPath for each icon.

    If the objShortcut.TargetPath = “some url or exe” delete it.

    Then copy the new Shortcut from a UNC location to the “DEFAULT USER” or “PUBLIC” desktop based on if it was W7 or XP.

    My assumption is that (And this is just the start….

    Basically if we deploy and icon for internal mail or whatever URL. Users may have renamed it to my mail or 123abc. I want to specifically attack the target either the URL or the *.exe and delete the icon and replace it. But then put that in the ALLUSERS or PUBLIC desktop so everyone gets the icon. Yes, multiple profiles on the PC. So there can be many unique names for them.

    Code:
    ‘********** START OF SCRIPT *******************

    ‘Create Objects
    Set objShell = CreateObject(“WScript.Shell”)
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    ‘Set to local computer name
    strComputer = “.”
    ‘Connect to computer WMI Service
    Set objWMI = GetObject(“winmgmts:\” & strComputer & “rootCIMV2”)
    ‘Get Operating System Information
    Set colItems = objWMI.ExecQuery(“SELECT * FROM Win32_OperatingSystem”,, 48)
    ***But what about X64?? ****
    For Each objItem In colItems
    strOSversion = objItem.Version
    Next
    strOSversion = Left(strOSversion, 3)
    ‘Check Version and run correct sub
    Select Case strOSversion
    Case “5.0”
    WinXP
    Case “5.1”
    WinXP
    Case “6.0”
    Win7
    Case “6.1”
    Win7
    End Select

    Sub WinXP
    For each profile if objShortcut.TargetPath = xyz
    then delete object
    then for %DefaultUser copy new icon from UNC

    Sub Win7
    For each profile if objShortcut.TargetPath = xyz
    then delete object
    then for %Public Desktop copy new icon from UNC

    ‘********** ENDOF SCRIPT *******************

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.