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

Shortcut Information

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

ShortCutInfo Returns Blank Target

 Keywords: ShortCutInfo Return Empty Blank Target Path

Question:

On Windows XP, when I run ShortCutinfo on a .lnk file that resides on a remote server, I get back a blank string for the target. The strange thing is that another .lnk file on the same server returns it target just fine.
************************************************************

*** Debug Initialized ***

==============================
Mon 5/10/2010 10:49:40 AM
WinBatch 32 2009C
WIL DLL 6.09cic
O:\WINBATCH\Routines\Setup.exe
Windows platform: NT, version: 5.1, build: 2600 (Service Pack 3)
ErrorMode: @CANCEL
==============================

rpth = "\\main\dummy\"
(16) VALUE STRING => "\\main\dummy\"

rslt = WinMetrics(-7)
(16) VALUE INT => 0

Select rslt
(16) CASE TRUE==>0

msk = "R*32.*"
(16) VALUE STRING => "R*32.*"

Break
(16) END OPERATOR

dirlst = DirItemize(Strcat(rpth,msk))
(16) VALUE UNICODE => R2011Networkx32	R2011Standalonex32	RMEP2011Networkx32	RMEP2011Standalonex32

dfldr = AskItemList("Deployment Folders",dirlst,@TAB,@SORTED,@SINGLE,@TRUE)
(4469) VALUE UNICODE => R2011Standalonex32

lnkfil = Strcat(rpth,dfldr,"\",dfldr,".lnk")
(4469) VALUE UNICODE => \\main\dummy\R2011Standalonex32\R2011Standalonex32.lnk

lst = ShortcutInfo(lnkfil)
(4516) VALUE STRING => "	/qb /I \\Main\dummy\R2011Standalonex32\AdminImage\R2011Standalonex32.ini	\\Main\dummy\R2011Standalonex32\AdminImage	2				0"

exit
(4516) VALUE INT => 0

--- Normal termination ---

;;;END OF JOB;;;

Answer:

We were able to reproduce the problem running on Windows XP SP3. Apparently this issue is specific to Windows XP when accessing remote lnks via UNC. We believe we may have found the fix to the issue. We plan on implementing this bug fix in the next release of WinBatch(2010B). We appreciate taking the time to contact us and help us track down the issue. In the meanwhile, I recommend that you use this Shell COM code which seems to work.
#DefineFunction udfShortCutInfo( lnkfile )
   ; ShortcutInfo returns a TAB-delimited list containing the following items (some of which may be blank):
   ;
   ; Arguments
   ; Contains a link's arguments.
   ;
   ; Description
   ; Gets the description of the link.
   ;
   ; Hotkey
   ; Gets the keyboard shortcut for the link.
   ;
   ; Path
   ; Gets the path to the link object.
   ;
   ; ShowCommand
   ; Gets the initial display state (sized, minimized, or maximized) of the link's command.
   ;
   ; WorkingDirectory
   ; Gets working directory specified in the link.

   objShApp = CreateObject("shell.application")
   objNamespace = objShApp.namespace(FilePath(lnkfile))
   objFile = objNamespace.parsename(StrCat(FileRoot(lnkfile),".",FileExtension(lnkfile)))
   objShellLink = objFile.GetLink
   path = objShellLink.path
   args = objShellLink.arguments
   workdir = objShellLink.workingdirectory
   desc = objShellLink.description
   hotkey = objShellLink.hotkey
   showcmd = objShellLink.showcommand
   objShellLink = 0
   objFile = 0
   objNamespace = 0
   objShApp = 0
   Return path:@TAB:args:@TAB:workdir:@TAB:desc:@TAB:hotkey:@TAB:showcmd
#EndFunction


desktop = ShortCutDir( 'Desktop' )
lnkfile = desktop: '\dummy.lnk'
info = udfShortCutInfo( lnkfile )
AskItemlist(lnkfile, info, @TAB, @UNSORTED, @SINGLE)
Exit
Reference: http://msdn.microsoft.com/en-us/library/bb774004(VS.85).aspx
Article ID:   W18279
Filename:   ShortCutInfo Returns Blank Target.txt
File Created: 2010:05:12:09:41:08
Last Updated: 2010:05:12:09:41:08