Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: shortcuts  (Read 5794 times)

0 Members and 1 Guest are viewing this topic.

feras

    Topic Starter


    Beginner

    Thanked: 1
  • Experience: Experienced
  • OS: Linux variant
shortcuts
« on: February 12, 2010, 01:16:55 AM »
Hello everybody :)

Is there ic CMD any code can delete the shortcuts which don't have targets ?

thanks

BillRichardson



    Intermediate

    Thanked: 15
    Re: shortcuts
    « Reply #1 on: February 12, 2010, 06:43:15 AM »

    C:\Documents and Settings\Bill Richardson\Desktop>dir  awk*
     Volume in drive C has no label.
     Volume Serial Number is F4A3-D6B3

     Directory of C:\Documents and Settings\Bill Richardson\Desktop

    12/17/2009  07:47 PM               186 Awk.url
                   1 File(s)            186 bytes
                   0 Dir(s)  299,962,126,336 bytes free

    C:\Documents and Settings\Bill Richardson\Desktop>del Awk.url
    Bill Richardson

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: shortcuts
    « Reply #2 on: February 12, 2010, 07:03:20 AM »
    C:\Documents and Settings\Bill Richardson\Desktop>dir  awk*
     Volume in drive C has no label.
     Volume Serial Number is F4A3-D6B3

     Directory of C:\Documents and Settings\Bill Richardson\Desktop

    12/17/2009  07:47 PM               186 Awk.url
                   1 File(s)            186 bytes
                   0 Dir(s)  299,962,126,336 bytes free

    C:\Documents and Settings\Bill Richardson\Desktop>del Awk.url
    I think the OP wants to CHECK whether or not shortcuts works and then delete them if they don't.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    BillRichardson



      Intermediate

      Thanked: 15
      Re: shortcuts
      « Reply #3 on: February 12, 2010, 08:05:45 AM »
      I think the OP wants to CHECK whether or not shortcuts works and then delete them if they don't.

      So please write the batch code that checks if the shortcut works.
      Bill Richardson

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: shortcuts
      « Reply #4 on: February 12, 2010, 02:58:18 PM »
      Quote
      Is there ic CMD any code can delete the shortcuts which don't have targets ?
      Not that I'm aware of.

      Quote
      C:\Documents and Settings\Bill Richardson\Desktop>del Awk.url
      Shortcuts have .lnk extensions, not .url

      You can write a VBScript:
      Code: [Select]
      strComputer = "."

      Set fso = CreateObject("Scripting.FileSystemObject")
      Set WshShell = CreateObject("Wscript.Shell")

      Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Extension = 'lnk'")

      For Each objFile in colFiles
      Set objFile = fso.GetFile(objFile.Name)
      If Not objFile.Attributes And 2 Then
        Set objShortcut = WshShell.CreateShortcut(objFile.Path)
      strTarget = objShortcut.TargetPath
        If Not fso.FileExists(strTarget) Then
        WScript.Echo "Target File: " & strTarget & " does not exist for shortcut: " & objFile.Path
        End If
        End If 
      Next

      The snippet will search the entire data store of files, irregardless of what drive they are on. Expect a lengthy run time. Save the script with a vbs extension and run from the command prompt as cscript scriptname.vbs.

      The snippet will list all the shortcuts with invalid target paths. When you are completely satisfied, replace the WScript.Echo line with fso.DeleteFile objFile.Path, True

      Good luck.  8)

      Quote
      I think the OP wants to CHECK whether or not shortcuts works and then delete them if they don't.
      Quote
      So please write the batch code that checks if the shortcut works.

      Sounds like a throwdown to me. How about a gun duel at 20 paces? The winner gets to write the batch file, the loser gets buried nine edge down  ;D
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      BillRichardson



        Intermediate

        Thanked: 15
        Re: shortcuts
        « Reply #5 on: February 12, 2010, 03:56:43 PM »
        "Shortcuts have .lnk extensions, not .url"

        http://msdn.microsoft.com/en-us/library/3eahbt2c(VS.85).aspx

        The shortcut pathname must end with .lnk or .url

        http://msdn.microsoft.com/en-us/library/3eahbt2c(VS.85).aspx

         
        The shortcut pathname must end with .lnk or .url

        When you named your shortcut, either you did not give it a file extension

        or you gave it an extension other than *.lnk, nor *.url.

        When using the CreateShortcut method, the file extension is incorrect
         
        or missing.

        To correct this error
        Check that the file extension for the shortcut ends

        with .lnk for a Windows shortcut or with .url for an Internet shortcut.

        Bill Richardson

        Prince_



          Beginner

          Thanked: 5
          Re: shortcuts
          « Reply #6 on: February 16, 2010, 06:24:29 PM »
          if it's named "a", then you can delete it like this
          Code: [Select]
          del a.lnk

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: shortcuts
          « Reply #7 on: February 16, 2010, 07:26:00 PM »
          Not everyone has deleted the registry keys which disable the viewing of certain extensions (including .lnk), and if those registry keys are in affect, the command prompt will not see those extensions, nor will the Windows GUI. The registry keys were NeverShowExt if I am not mistaken, but before any registry modification should be made (one should really avoid doing them anyway unless you know EXACTLY what you are doing and how it will affect your computer), always, ALWAYS, preform a backup of your registry.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: shortcuts
          « Reply #8 on: February 17, 2010, 03:11:27 AM »
          Not everyone has deleted the registry keys which disable the viewing of certain extensions (including .lnk), and if those registry keys are in affect, the command prompt will not see those extensions, nor will the Windows GUI. The registry keys were NeverShowExt if I am not mistaken, but before any registry modification should be made (one should really avoid doing them anyway unless you know EXACTLY what you are doing and how it will affect your computer), always, ALWAYS, preform a backup of your registry.

          the command line can always see the "lnk" extension. and I imagine the url extension too.

          the URL extension is of course completely irrelevant here since you cannot check if a URL exists easily.
          I was trying to dereference Null Pointers before it was cool.

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: shortcuts
          « Reply #9 on: February 17, 2010, 06:21:30 AM »
          the command line can always see the "lnk" extension. and I imagine the url extension too.

          the URL extension is of course completely irrelevant here since you cannot check if a URL exists easily.
          Not for me. I had to delete the registry keys to be able to view them in GUI and in the command prompt.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.