Sign in to follow this  
Followers 0
Necromorph

FileDelete

5 posts in this topic

any ideas why this isn't deleting the file $tEmpDir?

;Keyfinder by thomas malkewitz mcp mcdst

$tEmpDir = ("C:\" & @ComputerName & ".txt")
$tKeyLog = FileOpen("c:\Keys.txt", 1)

    
FileInstall("keyfinder.exe", @TempDir & "keyfinder.exe")
ShellExecute(@TempDir & "keyfinder.exe")
WinWait("Magical Jelly Bean Keyfinder v2.0.1")
Send("!f")
Send("s")
Sleep(500)
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", $tEmpDir)
Sleep(500)
Send("{ENTER}")
Sleep(500)
WinWaitClose("Save As")
ProcessClose("Tempkeyfinder.exe")
FileOpen($tEmpDir, 0)
$tKeys = FileRead($tEmpDir)
FileWrite($tKeyLog, @CR & @ComputerName & @CRLF & $tKeys)
FileClose($tKeyLog)
FileClose($tEmpDir)
FileDelete($tEmpDir)
FileDelete(@TempDir & "keyfinder.exe")
Exit

thanks.

Share this post


Link to post
Share on other sites



Mabey try and do some more error checking.

Make sure file exists:

If not FileExists($tEmpDir) then Msgbox(0,'','file does not exist')

Make sure file closed properly.

If Not FileClose($tEmpDir) then Msgbox(0,'','error closing file')

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thanks for the tip

i did try this, and it is getting an error on "closing the file" do i need a sleep command, or something in there?

thanks

$varDir = "C:\"
$varFile = $varDir & @ComputerName & ".txt"
$varKeyFile = FileOpen("c:\Keys.txt", 1)

FileInstall("keyfinder.exe", @TempDir & "keyfinder.exe")
ShellExecute(@TempDir & "keyfinder.exe")
WinWait("Magical Jelly Bean Keyfinder v2.0.1")
Send("!f")
Send("s")
Sleep(500)
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", $varFile)
Sleep(500)
Send("{ENTER}")
Sleep(500)
WinWaitClose("Save As")
ProcessClose("Tempkeyfinder.exe")
Sleep(250)
FileOpen($varFile, 0)
    While 1
        $varKeys = FileRead($varFile)
        FileWrite($varKeyFile, @CRLF & @ComputerName & @CRLF & $varKeys)
        ExitLoop
    WEnd
FileClose($varFile)
FileClose($varKeyFile)
FileDelete($varFile)
    If FileClose($varFile) Then
        FileDelete(@TempDir & "keyfinder.exe")
    Else
        MsgBox(0, "redLabel keyFinder", "error closing file")
    EndIf
Exit
Edited by redLabel

Share this post


Link to post
Share on other sites

well, i got it to work. im still not sure why, but if i assign a $var to the FileOpen($varFile), then it works, here is the code

$varDir = "C:\"
$varFile = $varDir & @ComputerName & ".txt"
$varKeyFile = FileOpen("c:\Keys.txt", 1)

FileInstall("keyfinder.exe", @TempDir & "keyfinder.exe")
    If FileExists($varFile) Then
        FileDelete($varFile)
    EndIf
ShellExecute(@TempDir & "keyfinder.exe")
WinWait("Magical Jelly Bean Keyfinder v2.0.1")
Send("!f")
Send("s")
Sleep(500)
ControlSend("Save As", "", "[CLASS:Edit; INSTANCE:1]", $varFile)
Sleep(500)
Send("{ENTER}")
Sleep(500)
WinWaitClose("Save As")
ProcessClose("Tempkeyfinder.exe")
Sleep(250)
$varFileOpen = FileOpen($varFile, 0)
$varKeys = FileRead($varFile)
FileWrite($varKeyFile, @CRLF & @ComputerName & @CRLF & $varKeys)
FileClose($varFileOpen)
FileDelete($varFile)
FileDelete(@TempDir & "keyfinder.exe")
Exit

Share this post


Link to post
Share on other sites

well, i got it to work. im still not sure why, but if i assign a $var to the FileOpen($varFile), then it works, here is the code

How can you NOT be sure? The helpfile clearly say for FileClose:

The handle of a file, as returned by a previous call to FileOpen.

Not a single word there or in FileOpen about any filename.

Seriously, use the helpfile next time, or you will find that more and more people will ignore you.

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