View Full Version : Shell.CreateShortcut problem
leebos
08-13-2008, 02:30 PM
I have a problem with the "target" file path being truncated after the 8th character in the second line of code below. The first is ok and they are identical except for the drive letter, which is a remote network drive.
Does anyone have an idea as to why it is being truncated?
Shell.CreateShortcut(icon_folder, icon_name, bpath..batchname, save, utsfolder, utsfolder.."\\wise.ico", 0, 7, nil);
Shell.CreateShortcut(icon_folder, "WKS_"..icon_name, targetp, "", remote_utsfolder, remote_utsfolder.."\\wise.ico", 0, 7, nil);
Thanks,
Lee
Derek
08-13-2008, 03:13 PM
What's the value of targetp? Have you tried using UNC instead?
leebos
08-13-2008, 03:41 PM
What's the value of targetp? Have you tried using UNC instead?
targetp is Z:\UTS07\TWICONS\CenRidLib\CenRidLib.bat
UNC? please explain.
I just found that if the remote drive is mapped, or it is an encrypted drive that is mounted it works ok. But if the remote drive is not available when the code is run the "b" is truncated from CenRidLib in both places.
Could this be an AMS bug?
Lee
longedge
08-13-2008, 03:54 PM
UNC (Universal Naming Convention) or a way to address a network resource in the format "\\servername\foldername\subfoldername\filename".
FWIW I'd go further than Derek and say if you are addressing networked resources, then never never ever use drive names e.g. "Z:/foldername/filename".
The way drives are mapped for one user will inevitably be different for someone else.
If it's just a drive attached to your own machine and you are the only one who is going to use the application that's a different matter.
p.s. - The forum is adding spaces again!! I didn't put a space in "filename" at the end of the first sentence.
leebos
08-13-2008, 04:04 PM
Thanks longedge. At the point I'm building this app the server name is unknown, and will vary. However, every workstation that the shortcut is to be used on will have drive Z mapped to the correct server.
Lee
Derek
08-13-2008, 04:12 PM
I just tested this and had the same problem. The 'b' is missing in both places when specifying an unavailable mapped drive.
UNC did work, however. Tho if the server name is unknown/variable it could prove a little difficult!
longedge
08-13-2008, 04:18 PM
Thanks longedge. At the point I'm building this app the server name is unknown, and will vary. However, every workstation that the shortcut is to be used on will have drive Z mapped to the correct server.
Lee
As long as you are aware of the potential problem that's fine. In our organisation I would only ever use fully qualified UNC's. Drive mapping is very useful but can sometimes be a double edged sword :)
leebos
08-13-2008, 04:19 PM
Thanks Derek, I posted it as a bug in the suggestions/bugs forum. Possibly IR can fix it.
Lee
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.