ricky Posted August 13, 2008 Share Posted August 13, 2008 (edited) Hello,How can I do to found a shotcut in the startup menu with a specific path?Explain : I know the path of a softwareI don't know the name of the shortcutIn the startup menu I have a lot of shotcutsI want to found the shortcut with this path and delete itI found this fonction FileGetShortcut but I don't know how to realise my needs.Thanks in advance for your help Edited August 13, 2008 by ricky03 Link to comment Share on other sites More sharing options...
Achilles Posted August 13, 2008 Share Posted August 13, 2008 You'll need several functions for this. First, look up _FileListToArray() in the helpfile as well as the @StartupDir. Using something similar to this (I haven't tested it) you will be able to list all the shortcuts in your startup: $shortCuts = FileListToArray(@StartupDir, '*.lnk', 1)Then you'll need to go through each of those shortcuts and check if it has the path you want, like this (again, not tested): For $i = 1 to $shortCuts[0] If FileGetShortcut($shortCuts[$i]) = 'Put your path here' then FileDelete($shortCuts[$i]) Exit;or maybe return if this just a function EndIf NextThe FileDelete obviously deletes the shortcut. Let me know if you didn't get any of that. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
ricky Posted August 13, 2008 Author Share Posted August 13, 2008 Thanks for your response. I try with this one : #Include <File.au3> #Include <Array.au3> ... Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SoftwareTest", "InstallLocation") & "RunTest.exe" Local $shortCuts = _FileListToArray(@StartupDir, '*.lnk', 1) Local $shortCutsCommon = _FileListToArray(@StartupCommonDir, '*.lnk', 1) ... DeleteShortcut($shortCuts,@StartupDir) DeleteShortcut($shortCutsCommon,@StartupCommonDir) ... Func DeleteShortcut($value,$directory) For $i = 1 to $value[0] If FileGetShortcut("$directory\$value[$i]") == '$sFile' then FileDelete("$directory\$value[$i]") CloseWindow() return EndIf Next EndFunc And I have the error in attachment. Link to comment Share on other sites More sharing options...
ricky Posted August 14, 2008 Author Share Posted August 14, 2008 I correct a lot of problems in my code, but the problem is the same, Somebody can correct my problems ore mistakes? #Include <File.au3> #Include <Array.au3> ... Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SoftwareTest", "InstallLocation") & "RunTest.exe" DIM $shortCuts = _FileListToArray(@StartupDir, '*.lnk', 1) DIM $shortCutsCommon = _FileListToArray(@StartupCommonDir, '*.lnk', 1) DeleteShortcut($shortCuts,@StartupDir) DeleteShortcut($shortCutsCommon,@StartupCommonDir) ... Func DeleteShortcut(ByRef $value,$directory) If $value[0]<> 0 Then For $i = 1 to $value[0] $details = FileGetShortcut($directory & "\" & $value[$i] & ".lnk") If $details[0] == $sFile then FileDelete($details) CloseWindow() return EndIf Next EndIf EndFunc The error is the same... Thanks in advance Link to comment Share on other sites More sharing options...
rasim Posted August 14, 2008 Share Posted August 14, 2008 ricky03Example:expandcollapse popupDim $program = "C:\Program Files\AutoIt3\Au3Info.exe" Dim $path = @StartMenuCommonDir & "\Programs" $shortcut = _Search($path) MsgBox(0, "Result", $shortcut) Func _Search($sPath) Local $search = FileFindFirstFile($sPath & "\*.*") If $search = -1 Then Return While 1 Local $iFile = FileFindNextFile($search) If @error Then Return False If StringInStr(FileGetAttrib($sPath & "\" & $iFile), "D") Then Local $iLNK = _SearchSubDir($sPath & "\" & $iFile) If $iLNK Then Return $iLNK EndIf If StringRight($iFile, 4) = ".lnk" Then Local $aParams = FileGetShortcut($sPath & "\" & $iFile) If StringInStr($aParams[0], $program) Then Return $sPath & "\" & $iFile EndIf WEnd FileClose($search) EndFunc Func _SearchSubDir($sPath) Local $search = FileFindFirstFile($sPath & "\*.*") If $search = -1 Then Return False While 1 Local $iFile = FileFindNextFile($search) If @error Then Return False If StringRight($iFile, 4) = ".lnk" Then Local $aParams = FileGetShortcut($sPath & "\" & $iFile) If StringInStr($aParams[0], $program) Then Return $sPath & "\" & $iFile EndIf EndIf WEnd FileClose($search) EndFunc Link to comment Share on other sites More sharing options...
ricky Posted August 14, 2008 Author Share Posted August 14, 2008 Hello, thanks for your reply, but, I don't understand... Link to comment Share on other sites More sharing options...
rasim Posted August 14, 2008 Share Posted August 14, 2008 Hello,thanks for your reply, but, I don't understand...What exactly you don`t understand? Link to comment Share on other sites More sharing options...
ricky Posted August 14, 2008 Author Share Posted August 14, 2008 I'm newbie and I need to understand each line, but i found the best solution for me : $sFile = "C:\Program Files\Sophos\AutoUpdate\ALMon.exe" $path = @StartupCommonDir _Search($path) Func _Search($sPath) Local $search = FileFindFirstFile($sPath & "\*.lnk") If $search = -1 Then Return While 1 Local $iFile = FileFindNextFile($search) If @error Then Return False Local $aParams = FileGetShortcut($sPath & "\" & $iFile) If StringInStr($aParams[0], $sFile) Then FileDelete($sPath & "\" & $iFile) EndIf WEnd FileClose($search) EndFunc Thanks a lot for your help... Link to comment Share on other sites More sharing options...
ricky Posted August 15, 2008 Author Share Posted August 15, 2008 More one question, why did you use FileClose($search)? There is no Fileopen... Link to comment Share on other sites More sharing options...
Achilles Posted August 15, 2008 Share Posted August 15, 2008 More one question, why did you use FileClose($search)? There is no Fileopen...FileFindFirstFile() returns a handle for a file which should be closed when you're done with the file. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
ricky Posted August 15, 2008 Author Share Posted August 15, 2008 Thanks for your help very useful. Regards 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