Jump to content

Delete link instead of target


ur
 Share

Recommended Posts

I wrote below code to delete a file.

But when I am trying to delete a shortcut, it it deleting target file instead of shortcut when I created a context menu entry for this executable.

The executable is working fine if we use it normally instead of context menu.But with COntext menu it is taking the target instead of shortcut.

 

By using the below registries.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Delete Permanently\command]
@="\"C:\\Program Files\\Permanent Delete\\Delete Permanently.exe\" \"%1\""

And compiled the below code to executable.

 

DeleteFile($CmdLine[$i]) ; Adding the path through CMD line argument.

Func DeleteFile($sFilePath)
    Local $iDelete = FileDelete($sFilePath)

    ; Display a message of whether the file was deleted.
    If $iDelete Then
        MsgBox($MB_ICONINFORMATION, "Deleting ...", "The file was successfuly deleted: " & $sFilePath,10)
    Else
        MsgBox($MB_ICONERROR, "Deleting ...", "An error occurred while deleting the file: " & $sFilePath & @CRLF & "Please check whether it is in use by any process",10)
    EndIf
EndFunc

 

Link to comment
Share on other sites

It seems to be a desired behaviour from Windows.

You have to add an additional entry specially for the lnk files :

[HKEY_CLASSES_ROOT\lnkfile\shell\Delete Permanently\command]
@="\"C:\\Program Files\\Permanent Delete\\Delete Permanently.exe\" \"%1\""

 

 

Link to comment
Share on other sites

It seems to be a desired behaviour from Windows.

You have to add an additional entry specially for the lnk files :

[HKEY_CLASSES_ROOT\lnkfile\shell\Delete Permanently\command]
@="\"C:\\Program Files\\Permanent Delete\\Delete Permanently.exe\" \"%1\""

 

 

It worked... Many Thanks. :)

Link to comment
Share on other sites

I got a different issue now and the context menu is not coming for .url files. I tried the similar approach used for lnkfile and tried in hive InternetShortcut but even with system user rights also I am not able to add registries to this hive.

HKEY_CLASSES_ROOT\InternetShortcut\shell

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

×
×
  • Create New...