Sign in to follow this  
Followers 0
JSThePatriot

Delete a Shortcut...

25 posts in this topic

I have searched the forums, and have tried many things myself. I know exactly where the shortcut is and its proper name, but I cannot delete it. I cant even do a FileDelete("*.lnk"), I even tried FileDelete("*.*") in a folder that had only short cuts in it.

I am trying to customize a programs installation, and that requires the option to delete the shortcuts (on the desktop) since the installer doesnt ask.

Please inform me of any possible option.

I am on Windows XP Pro, but this should be portable to all the Windows OS's

TIA,

JS


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)

Share this post


Link to post
Share on other sites



dos command "del" will delete it. --> Run(....)

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

dos command "del" will delete it. --> Run(....)

Cheers

Kurt

<{POST_SNAPBACK}>

Hrm. I guess that would work. I would have to check which operating system they were on.

I will see. In the mean time if anyone else comes up with different options please let me know.

I dont understand why FileDelete() doesnt work.

JS


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)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I was trying to retrieve info on a shortcut on my desktop through the FileGetShortcut() and it always returned error.

FIleExists didnt work either...By the way it was acrobat Reader's shortcut (adobe.lnk).

dim $var[7]
If FileExists(@desktopdir & "\Adobe.lnk") then Msgbox(0,"","FOUND")
$var=FileGetShortcut(@desktopdir & "\adobe.lnk")
if @error then MsgBox(0,"","ERROR")
For $i=0 to 6
MsgBox(0,"",$var[$i])
Next

EDIT:Added code

Edited by hgeras

Share this post


Link to post
Share on other sites

Both AutoIT functions FileExists() and FileDelete() use FindFirstFile() (win32 API) in the source code. So, I guess FindFirstFile() fails to find a shortcut, and thus returns INVALID_HANDLE_VALUE. - utility.cpp:717 (public source).

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

It is possible for FileExists() and FileDelete() not to work for the reason you said.But what about the FileGetShortcut()?It is supposed to handle Shortcuts....

<{POST_SNAPBACK}>

FileGetShortcut() also uses FileFindFirst() in function utiliy.cpp::Util_DoesFileExist(). However, I'm just speculating, as I did not try to troubleshoot the problem yet. Could well be another reason why the functions fail.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

FileDelete works for me. Am I missing something?


This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

FileDelete works for me. Am I missing something?

<{POST_SNAPBACK}>

maybe windows version?

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

maybe windows version?

Cheers

Kurt

<{POST_SNAPBACK}>

I'm on XPP SP2

I thought maybe because I don't leave the Windows default HKEY_CLASSES_ROOT\lnkfile\ "NeverShowExt"

that hides lnk extension but I set it back to default and FileDelete still works... :whistle:

::headscratch:: I also tried the non beta version of AutoIt. First time I've had trouble getting something to NOT work with AutoIt :dance:


This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

I believe it has something to do with the shortcuts that you make yourself and the shortcuts that are made through app installers....

Probably. Properties of the Adobe Reader shortcut. It seems that MSI setup files produce special shortcuts. Word,Excel,etc. have these "special" shortcuts in the Start Menu.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

The only problem I have with that theory, is the fact that all the shortcuts I am trying to delete dont have that 'special' stuff. It is created by an application, but still it should be allowed to be deleted. Oh well... I will have to come up with another way to go about this. Maybe just set the attribute hidden, but if the person has hidden objects showing it wont work :whistle:

If anyone else comes up with something let me know.

JS


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)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I have here XP and SP2 and at work SP1 and had never problems with creating and deleting shortcuts!?

Strange.... :whistle:

Really stupid question (I know): does deleting with "Del"-key work?

What I experience sometimes is that a virus scanner sometimes locks the file I want to delete...

Edited by Holger

Share this post


Link to post
Share on other sites

I have here XP and SP2 and at work SP1 and had never problems with creating and deleting shortcuts!?

Strange....  :whistle:

<{POST_SNAPBACK}>

Are you deleting shortcuts that you made or were made by programs? That seems to be the issue.

JS


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)

Share this post


Link to post
Share on other sites

Both is working here: I could also delete the Acrobat Reader-shortcut from my desktop (All Users) and could delete normal and 'special' shortcuts...

<{POST_SNAPBACK}>

What code are you using and are you using v3 or beta?

JS


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)

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Ohhhh...wait - I think I can reproduce.... :whistle:

Edit are you sure you used the right directory-macro:

@DesktopDir or it's maybe in 'All Users'-profile -> @DesktopCommonDir ?

Forgot: it works with release and beta versions.

I have no more ideas at the moment...

Edited by Holger

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I have no problems with mine... It must be a directory thing. Can you try reading/deleting other types of files in the same directory?

*Edit: The code I used was simple.

I created a shortcut called "short"

Then just FileDelete('short.lnk')

*Edit2: Some more expansive example code:

$v = FileCreateShortcut(@COMSPEC, @DesktopDir & '\short.lnk')
If $v Then
    MsgBox(0, '', 'Created')
    $v = FileDelete(@DesktopDir & '\short.lnk')
    If $v Then
        MsgBox(0, '', 'Deleted')
    Else
        MsgBox(0, '', 'Error deleting')
    EndIf
Else
    MsgBox(0, '', 'Error deleting')
EndIf

Works fine for me. How about you?

Edited by Saunders

Share this post


Link to post
Share on other sites

Ohhhh...wait - I think I can reproduce.... :whistle:

Edit are you sure you used the right directory-macro:

@DesktopDir or it's maybe in 'All Users'-profile -> @DesktopCommonDir ?

Forgot: it works with release and beta versions.

I have no more ideas at the moment...

<{POST_SNAPBACK}>

I'm unable to reproduce, sorry...

I tried several MSI packages (running msi V 3.01.4000.1823)

And I also tried some shortcuts created by a REAL installer like Inno...

I can't make it NOT work!!! :dance:


This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
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
Sign in to follow this  
Followers 0