Announcement

Collapse
No announcement yet.

how to delete shortcut via VB script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to delete shortcut via VB script

    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!

  • #2
    Re: how to delete shortcut via VB script

    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)

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: how to delete shortcut via VB script

      Originally posted by Rems View Post
      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)

      Works great!!! thanks Rems!!!

      Comment

      Working...
      X