Jump to content

Delete .Ink file


DigDeep
 Share

Recommended Posts

This might sound weird. Sometime ago I had created a script to install an app and create it's shortcut. Didn't realize that I accidentally gave the shortcut extension as '.Ink' as an i instead of '.lnk' as an L.

Now the issue is that I am able to delete the application and all it's dependencies except this shortcut file. If I want to upgrade the application with the correct extension as LNK file, I am getting 2 process running.

Is there a way to get the .ink deleted?

I tried FileDelete, Rename File and then delete (does not even rename), FileMove (Does not move). I already have #RequireAdmin declared at the top.

Link to comment
Share on other sites

@DigDeep
Something like this?

#include <File.au3>

CreateFiles()
DeleteInkFiles()

Func CreateFiles()

    Local $strFileName = ""

    ; InkFiles
    For $i = 1 To 10 Step 1
        $strFileName = @ScriptDir & "\Files\InkFile" & $i & ".ink"
        If Not _FileCreate($strFileName) Then Exit ConsoleWrite("Error while creating file '" & $strFileName & "'. Error: " & @error & @CRLF)
    Next

    ; Lnk Files
    For $i = 1 To 10 Step 1
        $strFileName = @ScriptDir & "\Files\LnkFile" & $i & ".lnk"
        If Not _FileCreate($strFileName) Then Exit ConsoleWrite("Error while creating file '" & $strFileName & "'. Error: " & @error & @CRLF)
    Next

EndFunc

Func DeleteInkFiles()

    Local $strFilesPath = @ScriptDir & "\Files", _
          $arrInkFiles

    $arrInkFiles = _FileListToArray($strFilesPath, "*", $FLTAR_FILES, True)
    _ArrayDisplay($arrInkFiles, "Before deleting:")

    $arrInkFiles = _FileListToArray($strFilesPath, "*.ink", $FLTAR_FILES, True)
    If @error Then
        ConsoleWrite("Error while getting the list of files. Error: " & @error & @CRLF)
    Else
        For $i = 1 To $arrInkFiles[0] Step 1
            If FileDelete($arrInkFiles[$i]) Then
                ConsoleWrite("The file '" & $arrInkFiles[$i] & "' has been deleted correctly." & @CRLF)
            Else
                ConsoleWrite("The file '" & $arrInkFiles[$i] & "' has not been deleted." & @CRLF)
            EndIf
        Next

        $arrInkFiles = _FileListToArray($strFilesPath, "*", $FLTAR_FILES, True)
        _ArrayDisplay($arrInkFiles, "After deleting:")

    EndIf

EndFunc

Cheers :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • 2 weeks later...

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...