mjg Posted October 1, 2007 Share Posted October 1, 2007 Can anyone tell me why this doesn't seem to be working properly: $search = FileFindFirstFile(@DesktopDir &"\CTMS*.lnk") If $search = -1 Then $search = FileFindFirstFile(@DesktopCommonDir &"\CTMS*.lnk") If $search = -1 Then MsgBox(0,"Error","CTMS Does not appear to be installed") Exit EndIf EndIf $string1 = FileFindNextFile($search) MsgBox(0,$string1,$string1) ; This displays the correct shortcut name ;FileClose($search);just tried this for testing $string2 = FileGetShortcut($string1) If @error Then MsgBox(0,"Error","Unknown Error") Exit EndIf MsgBox(0,$string2[1],$string2[1]) The only thing that doesn't seem to work is the FileGetShortCut with a variable. It errors out which gives me the unknown error message box. I've searched around the forum, and found a few places where it seems as if FileGetShortcut will work with a variable, but I just can't figure out what is wrong; I -mjg Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2007 Share Posted October 1, 2007 You have to provide the FULL path, not just the filename: $sPath = @DesktopDir $search = FileFindFirstFile($sPath & "\CTMS*.lnk") If $search = -1 Then $sPath = @DesktopCommonDir $search = FileFindFirstFile($sPath & "\CTMS*.lnk") If $search = -1 Then MsgBox(0, "Error", "CTMS Does not appear to be installed") Exit EndIf EndIf $string1 = $sPath & "\" & FileFindNextFile($search) MsgBox(0, "Found", $string1) $string2 = FileGetShortcut($string1) If @error Then MsgBox(0, "Error", "@errot = " & @error) Exit EndIf MsgBox(0, $string2[1], $string2[1]) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mjg Posted October 1, 2007 Author Share Posted October 1, 2007 You have to provide the FULL path, not just the filename: $sPath = @DesktopDir $search = FileFindFirstFile($sPath & "\CTMS*.lnk") If $search = -1 Then $sPath = @DesktopCommonDir $search = FileFindFirstFile($sPath & "\CTMS*.lnk") If $search = -1 Then MsgBox(0, "Error", "CTMS Does not appear to be installed") Exit EndIf EndIf $string1 = $sPath & "\" & FileFindNextFile($search) MsgBox(0, "Found", $string1) $string2 = FileGetShortcut($string1) If @error Then MsgBox(0, "Error", "@errot = " & @error) Exit EndIf MsgBox(0, $string2[1], $string2[1]) Ok, I'll give that a try, makes sense now. Thanks a lot for your help. -mjg Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now