Irongeek Posted July 1, 2009 Share Posted July 1, 2009 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 More sharing options...
Developers Jos Posted July 1, 2009 Developers Share Posted July 1, 2009 (edited) 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 July 1, 2009 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 More sharing options...
Irongeek Posted July 1, 2009 Author Share Posted July 1, 2009 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 More sharing options...
Irongeek Posted July 1, 2009 Author Share Posted July 1, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now