Jump to content
Sign in to follow this  
Irongeek

Wiping with Autoit

Recommended Posts

Irongeek

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.

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Irongeek

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

Share this post


Link to post
Share on other sites
Irongeek

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.

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  

×