BPBNA Posted August 3, 2006 Share Posted August 3, 2006 I can't seem to figure out how to do it... I thought just using FileDelete would work. FileDelete(@DesktopDir & "\My Link.lnk") It doesn't Can anyone tell me the correct way? I thought if there was a _FileCreateShortcut function then there must be a _FileDeleteShortcut too but aparently there isn't. Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 it might be on the AllUsers Desktop Try this UDF that checks both Desktops _Desktop('My Link.lnk') Func _Desktop($shortcut) ; Delete a Desktop shortcut. If FileExists(@DesktopDir & '\' & $shortcut) Then Return FileDelete(@DesktopDir & '\' & $shortcut) ElseIf FileExists(@DesktopCommonDir & '\' & $shortcut) Then Return FileDelete(@DesktopCommonDir & '\' & $shortcut) EndIf EndFunc Link to comment Share on other sites More sharing options...
BPBNA Posted August 3, 2006 Author Share Posted August 3, 2006 I know it isnt on the All Users desktop since I wrote the installer, but that still doesnt work anyways. =/ This is used to create it. I just cant see whats wrong with it! FileCreateShortcut(@ProgramFilesDir & "\My Directory\My File.exe", @DesktopDir & "\My Link.lnk") Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 Try it with double quotes around the path like this FileDelete('"' & @DesktopDir & '\My Link.lnk"') Link to comment Share on other sites More sharing options...
BPBNA Posted August 3, 2006 Author Share Posted August 3, 2006 No cigar. Link to comment Share on other sites More sharing options...
BPBNA Posted August 3, 2006 Author Share Posted August 3, 2006 (edited) In this uninstaller, I'm using the SelfDelete wrapper. I tried adding it to the batch file it creates Func _SelfDelete($iDelay = 0) Local $sCmdFile FileDelete(@TempDir & "\scratch.bat") $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _ & ':remfile' & @CRLF _ & 'if exist "' & @DesktopDir & "\My Link.lnk" & '" goto remlink' & @CRLF _ & 'del ' & @TempDir & '\scratch.bat' FileWrite(@TempDir & "\scratch.bat", $sCmdFile) Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE) EndFunc Even though if I go into a command prompt and type del "My Link.lnk" and it works, the batch file still doesn't work. Edited August 3, 2006 by BPBNA Link to comment Share on other sites More sharing options...
JSThePatriot Posted August 3, 2006 Share Posted August 3, 2006 May want to check this thread.ShortcutsI had a problem with this almost one year ago. I was forgetting the "\", I see that's not the case with you, but maybe you can get your issue resolved by looking through that topic. They presented me with alot of ideas.Have you tried...$ret = FileExists(@DesktopDir & "\My Link.lnk") If $ret Then MsgBox(0, "FileExists!", "File does exist!") Else MsgBox(0, "FileNonExistant!", "File does not exist!") EndIfJS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 (edited) The batch write does not look right. Try this Run(@ComSpec & ' /c del "' & @DesktopDir & '\My Link.lnk"') Do you have any files or folders on the desktop that start with "My "? Edit: Corrected syntax Edited August 3, 2006 by MHz Link to comment Share on other sites More sharing options...
bluebearr Posted August 3, 2006 Share Posted August 3, 2006 The script below worked for me as expected - the shortcut was created, there was a pause, and the shortcut was deleted. I added the two text files to investigate whether having other files that start with "My" might be interfering with the delete, as MHz suggested. I didn't have a problem. FileCreateShortcut(@ProgramFilesDir & "\AutoIt3\AU3Info.exe", @DesktopDir & "\My Link.lnk") FileWrite(@DesktopDir & '\My scrap text.txt', 'This is a test') FileWrite(@DesktopDir & '\My scrap text 2.txt', 'This is a test') WinMinimizeAll() Sleep(5000) FileDelete(@DesktopDir & "\My Link.lnk") sleep(1000) MsgBox(0, "Shortcut Delete", 'The shortcut "My Link" should not appear on the desktop.', 5) FileDelete(@DesktopDir & "\My scrap text.txt") FileDelete(@DesktopDir & "\My scrap text 2.txt") WinMinimizeAllUndo() So it seems that your syntax is correct, at least. May be a dumb question, but can you manually delete it? I'm wondering if there is a permission issue... BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
MHz Posted August 3, 2006 Share Posted August 3, 2006 (edited) Perhaps a timing issue with the installer closing after the last window if you are trying to delete the shortcut straight after the install? ProcessWaitClose() may help then. Surely you have a script to post and see if it is this or other issue? Edit: My last code had an ampersand missing... Edited August 3, 2006 by MHz Link to comment Share on other sites More sharing options...
BPBNA Posted August 3, 2006 Author Share Posted August 3, 2006 Ugh, I ALWAYS make stupid little mistakes like this. Turns out when I did the FileInstall in my setup script I kept using an old version of the uninstaller so none of the changes I made mattered. It is working now, thanks for the help! (yes some of it did help, that part wasn't the whole problem) 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