retterermoore
retterermoore

Reputation: 1

WinDbg scripting - how to delete a file?

I'm working with an existing framework of WinDbg scripts that go through a series of test scripts Test1.txt, Test2.txt, etc., which are generated by C++ code and which output results.

For example a chunk of one of the test scripts would be,

 .if (($spat(@"${var}","18300.000000")==1))
        {
            .logappend C:\Tests\TestResults.txt
            .printf "TestNumber=\t1\tExpected=\t18300.000000\tActual=\t%.6f\t******PASSED******\n",poi(poi(@$t2+@$t6)+0x10)
            .logclose
        }

I'm trying to add functionality that will create a file whose name displays the current # of the test being run, so that users can see their progress without needing to open a file.

My thought process was that I would set up the script generator, so that at the start of Test #N, it would add a line to the script to create a file 'currentlyRunningTestN.txt', and at the end of Test #N, it would add a line to the script to delete that file. However, I don't see any delete function in the WinDbg meta command glossary: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/meta-commands, or in the list of supported C functions like printf. Am I just missing something, or is deleting files not supported by WinDbg (or equivalently renaming files, which would also serve my purpose?) If deleting/renaming don't work, is there another way to achieve the functionality I'm looking for?

Upvotes: 0

Views: 248

Answers (1)

Thomas Weller
Thomas Weller

Reputation: 59513

With the .shell command, you can execute any DOS-like command. Although I never tried deleting a file, it should be possible.

As you may have noticed, WinDbg scripting does not always work on first attempt, please make sure your scripting will not result in a big data loss on your customer's PC whilst deleting files.

Upvotes: 0

Related Questions