Jump to content
Sign in to follow this  
DigDeep

Delete .Ink file

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.

Share this post


Link to post
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

doesn't make sense that you can't delete it unless the file names are actually FileName.ink.lnk since if they were actually .ink they shouldn't have even worked.


hmm... I guess I have to have a signature...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...