Jump to content

Array problems


Recommended Posts

#Region - Find shortcut for executable
$IsInShortcutDir = False
$SearchHandle = FileFindFirstFile(@StartupCommonDir & "\" & "*.lnk"); Find all .lnk files in the commen startup dir

If $SearchHandle <> - 1 Then; If any shortcut were founded.
    
    $ShortcutFile = FileFindNextFile($SearchHandle); Get first file
    
    While Not @error; Loop until no more files
        $ShortcutData = FileGetShortcut($ShortcutFile); Get details about the shortcut
        If $ShortcutData[0] = @ScriptFullPath Then; If shortcut leads to the executable
            $IsInShortcutDir = True; Then confirm it
            ExitLoop; And exit loop
        EndIf
        $ShortcutFile = FileFindNextFile($SearchHandle); Otherwise continue the search
    WEnd
    
EndIf
FileClose($SearchHandle); Close handle

If $IsInShortcutDir = True Then; If confirmed
    MsgBox(0,0,"Shortcut founded")
EndIf
#EndRegion - Find shortcut for executable

Anyone that can point out the error here? I get the "Subscript used with non-Array variable" error upon "If $ShortcutData[0] = ..." line. Why?

Thanks.

Link to comment
Share on other sites

You must use ABSOLUTE path

;      ConsoleWrite(@StartupCommonDir & '\' & $ShortcutFile & @LF)
       $ShortcutData = FileGetShortcut(@StartupCommonDir & '\' & $ShortcutFile); Get details about the shortcut
Doh thanks :P.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...