how to delete shortcut via VB script

Home Forums Scripting Windows Script Host how to delete shortcut via VB script

This topic contains 2 replies, has 2 voices, and was last updated by Rems Rems 9 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Avatar
    XtaZee
    Member
    #149192

    I’ve created the folowing script to create short cut on the desktop

    Code:
    set WshShell = WScript.CreateObject(“WScript.Shell” )

    strDesktop = WshShell.SpecialFolders(“Desktop” )

    set oShellLink = WshShell.CreateShortcut(strDesktop & “MyShortcut.lnk” )
    oShellLink.TargetPath = strDesktop & “MyShortcut.exe”
    oShellLink.WindowStyle = 1
    oShellLink.IconLocation = strDesktop & “MyShortcut.ico”
    oShellLink.Description = “MyShortcut”
    oShellLink.WorkingDirectory = strDesktop & “MyShortcut”
    oShellLink.Save

    Q: how to delete it using a script

    Thanks!

    Rems
    Rems
    Moderator
    #227719

    Re: how to delete shortcut via VB script

    set WshShell = WScript.CreateObject(“WScript.Shell” )
    strDesktop = WshShell.SpecialFolders(“Desktop” )

    ‘ delete this shortcut
    strShortcut = strDesktop & “[COLOR=”Navy”][B]MyShortcut[/B][/COLOR].LNK”

    Set fso = CreateObject(“Scripting.FileSystemObject”)
    If fso.FileExists(strShortcut) Then fso.DeleteFile(strShortcut)
    [/CODE][CODE]
    set WshShell = WScript.CreateObject(“WScript.Shell” )
    strDesktop = WshShell.SpecialFolders(“Desktop” )

    ‘ delete this shortcut
    strShortcut = strDesktop & “MyShortcut.LNK”

    Set fso = CreateObject(“Scripting.FileSystemObject”)
    If fso.FileExists(strShortcut) Then fso.DeleteFile(strShortcut)
    [/CODE]

    Avatar
    XtaZee
    Member
    #224358

    Re: how to delete shortcut via VB script

    Rems;205220 wrote:
    set WshShell = WScript.CreateObject(“WScript.Shell” )
    strDesktop = WshShell.SpecialFolders(“Desktop” )

    ‘ delete this shortcut
    strShortcut = strDesktop & “[COLOR=”Navy”][B]MyShortcut[/B][/COLOR].LNK”

    Set fso = CreateObject(“Scripting.FileSystemObject”)
    If fso.FileExists(strShortcut) Then fso.DeleteFile(strShortcut)
    [/CODE][/QUOTE]

    Works great!!! thanks Rems!!![CODE]
    set WshShell = WScript.CreateObject(“WScript.Shell” )
    strDesktop = WshShell.SpecialFolders(“Desktop” )

    ‘ delete this shortcut
    strShortcut = strDesktop & “MyShortcut.LNK”

    Set fso = CreateObject(“Scripting.FileSystemObject”)
    If fso.FileExists(strShortcut) Then fso.DeleteFile(strShortcut)
    [/CODE]

    Works great!!! thanks Rems!!!

Viewing 3 posts - 1 through 3 (of 3 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