Jump to content

Wiping with Autoit


Recommended Posts

Hi all, I'm trying to use Autoit to wipe a physical drive with all zeros. The following code gives no error:

$file = FileOpen("\\.\physicaldrive1",16)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
; Read in 1 character at a time until the EOF is reached
While 1
    ;$chars = FileRead($file, 100)
    ;If @error = -1 Then ExitLoop
    ;MsgBox(0, "Char read:", $chars)
    FileWrite($file, Chr("0"))
Wend

FileClose($file)

but it seems to make no change. Ideas? Thanks.

Link to comment
Share on other sites

  • Developers

Not sure but shouldn't that be:

$file = FileOpen("\\.\physicaldrive1",17)

To open it for Byte Write.

You aren't testing the success of FileWrite() to see if all works properly.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Not sure but shouldn't that be:

$file = FileOpen("\\.\physicaldrive1",17)

To open it for Byte Write.

You aren't testing the success of FileWrite() to see if all works properly.

Thanks, but using 17 gives an error, saying it can't open the file..

Link to comment
Share on other sites

I seriously doubt FileOpen() can open a Hard Drive, unless a Dev says otherwise.

You may want to take a look at AU3-SD. It has a function to wash empty disk space, just like what you are trying to do.

Hint: Creating a new file on that drive and writing the zeros into the file would accomplish your goal. (That's how AU3-SD does it.)

Thanks, I'll have to take a look at that lib, but I'd like to do a zero wipe down a whole drive.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...