WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinBatch Function UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Shortcut Type

 Keywords: Shortcut Type File Folder Directory lnk .lnk ShortCutEdit ShortCutInfo udfShortcutType

Question:

I have thousands or .LNK shortcuts that need to be modified due to a data migration. There both folder and file shorcuts. Is the shortcut type able to be determined from the shortcutinfo() or will I have to use both type 0 and type 1 in 2 lines of code to make the change to the target and startin As in :
ShortCutEdit(fShortcutName, sTarget, "", sWorkDir, @NORMAL,0)
ShortCutEdit(fShortcutName, sTarget, "", sWorkDir, @NORMAL,1)

Answer:

One way to determine the shortcut type might be by inspecting the target. For example I put together the following UDF to determine the shortcut type:
#DefineFunction udfShortcutType( linkname )
   ;----------------------------------------------------------------
   ; udfShortcutType( linkname )
   ;----------------------------------------------------------------
   ; Retunrs the type of shortcut: file or folder type
   ;----------------------------------------------------------------
   ; linkname : full file path and .lnk file name
   ;----------------------------------------------------------------
   ; returns: 0 if file, 1 if folder
   ;----------------------------------------------------------------
   ; notes :
   ;----------------------------------------------------------------
    result = ShortCutInfo( linkname )
    target =  ItemExtract( 1, result, @TAB )
    result = 0 ; assume file
    If DirExist(target)
        result = 1 ; folder
    EndIf
    Return result
#EndFunction

dir = 'D:\temp\Shortcut'
DirChange( dir )
lnks = FileItemize( '*.lnk' )
count = ItemCount( lnks, @TAB )
For i = 1 To count
    linkname = ItemExtract( i, lnks, @TAB )
    type = udfShortcutType( linkname)
    Switch type
       Case 0
          Pause( 'FILE LNK', linkname )
          Break
       Case 1
          Pause( 'FOLDER LNK', linkname )
          Break
    EndSwitch
Next
Exit

Article ID:   W18417
Filename:   Shortcut Type.txt
File Created: 2009:12:15:10:25:14
Last Updated: 2009:12:15:10:25:14