Call a description of an existing shortcut

Home Forums Scripting Windows Script Host Call a description of an existing shortcut

This topic contains 1 reply, has 2 voices, and was last updated by Rems Rems 8 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Avatar
    trt7g7
    Member
    #152703

    I have a script that I have been using for a while now that creates a shortcut in a folder in My Documents and sets a user input description to the created shortcut that can be shown in windows explorer by showing “Comments”.

    The script does multiple other things and may be ran multiple times for a given job so it is getting rather tedious to retype a description every time the script is ran. I would like for the script to check if the shortcut exists and if so automatically populate the user input box for the description (jobDescription) with the existing description.

    Here is the working part of the script:

    Code:
    JobDescription=Inputbox(“Optional: Enter a short description of the job”,”Job Description”, CurrentJob )
    If jobDescription = “” then
    jobDescription = CurrentJob
    end If
    set WshShell = WScript.CreateObject(“WScript.Shell”)
    strDocuments = “C:Documents and Settings” & name & “My DocumentsReleased Jobs”
    strLink = strDocuments & “” & job & “.lnk”
    set oShellLink = WshShell.CreateShortcut(strLink)
    oShellLink.TargetPath = “\okcsxds01TSJobsactiveENG” & job & “”
    oShellLink.Description = JobDescription
    oShellLink.WorkingDirectory = “\okcsxds01TSJobsactiveENG” & job & “”
    oShellLink.Save

    Any help/suggestions would be greatly appreciated.

    Thanks,
    Tyler

    Rems
    Rems
    Moderator
    #227918

    Re: Call a description of an existing shortcut

    check if the shortcut exists and, if so automatically populate the user input box for the description (jobDescription) with the existing description:

    Code:
    Const CSIDL_MY_DOCUMENTS = &H5&

    CurrentJob = “[COLOR=”Red”]missing variable 1[/COLOR]”
    job = “[COLOR=”red”]missing variable 2[/COLOR]”

    strDocuments = GetSpecialFolder(CSIDL_MY_DOCUMENTS) & “Released Jobs”
    strLink = strDocuments & “” & job & “.lnk”

    set WshShell = WScript.CreateObject(“WScript.Shell”)
    Set fso = CreateObject(“scripting.filesystemobject”)

    set oShellLink = WshShell.CreateShortcut(strLink)

    If fso.FileExists(strLink) Then
    jobDescription = oShellLink.Description
    JobDescription = Trim( _
    Inputbox(“Optional: Enter a new short description of the job”, _
    “Job Description”, jobDescription ))
    End If

    If jobDescription = “” then
    jobDescription = CurrentJob
    End If

    oShellLink.TargetPath = “\okcsxds01TSJobsactiveENG” & job & “”
    oShellLink.Description = JobDescription
    oShellLink.WorkingDirectory = “\okcsxds01TSJobsactiveENG” & job & “”

    If NOT fso.FolderExists(strDocuments) Then fso.CreateFolder(strDocuments)
    oShellLink.Save

    Function GetSpecialFolder(sfolder)
    With CreateObject(“Shell.Application”)
    With .Namespace(sfolder)
    GetSpecialFolder = .Self.Path
    End With
    End With
    End Function

    Rems

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Register for this Petri Webinar!

Software-Defined Unlimited Backup Storage

Tuesday, August 27, 2019 @ 1:00 pm EDT

A Scale-Out Backup storage infrastructure is a must-have technology for your backups. In this webinar, join expert Rick Vanover for a look on what real-world problems are solved by the Scale-Out Backup Repository.

Register Now

Sponsored By