1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows Automatic diskpart?

Discussion in 'Software' started by MonkeyBoss, 12 Mar 2012.

  1. MonkeyBoss

    MonkeyBoss What's a Dremel?

    Joined:
    24 Jan 2012
    Posts:
    162
    Likes Received:
    11
    I wipe a lot of hard drives in work and was wondering how i could go about getting diskpart to run automatically. can it be done with a batch file?

    the commands i run are

    SELECT DISK 2
    CLEAN
    CREATE PARTITION PRIMARY
    FORMAT FS=NTFS QUICK
    ACTIVE
    ASSIGN


    any help would be great

    thanks
     
  2. deathtaker27

    deathtaker27 Modder

    Joined:
    17 Apr 2010
    Posts:
    2,238
    Likes Received:
    186
    batch file it?
     
  3. MonkeyBoss

    MonkeyBoss What's a Dremel?

    Joined:
    24 Jan 2012
    Posts:
    162
    Likes Received:
    11
    how would i create a batch file for it? never used them before
     
  4. Margo Baggins

    Margo Baggins I'm good at Soldering Super Moderator

    Joined:
    28 May 2010
    Posts:
    5,649
    Likes Received:
    268
    for diskpart you can't put the diskpart inside a batch script as it opens its own shell, you need to do..

    diskpart /s diskpart.txt

    you have to make a text files called diskpart.txt and put it inside one of your "paths". inside diskpart.txt put..

    SELECT DISK 2
    CLEAN
    CREATE PARTITION PRIMARY
    FORMAT FS=NTFS QUICK
    ACTIVE
    ASSIGN
    EXIT

    Thought I have never tried it, you could probably then make a batch file of the diskpart /s diskpart.txt

    Somethin like,

    @echo off

    echo About to run diskpart...

    diskpart /s diskpart.txt

    echo Diskpart complete!

    pause

    To save the above bit as a batch file, put it in a text file and change file type to all files and save as whatever.bat then it will be a batch file :)

    Then it should hopefully run diskpart with your text file input, then pause for input before it closes the script window.

    (to see what/where your paths are, open cmd and write "set" then look for PATHS, it should be a list of folders where you can have stuff and just reference it from command line and it will use it without having to have the full path input, you can add and change these paths.)

    EDIT: found it, here is the microsoft KB about scripting diskpart http://technet.microsoft.com/en-us/library/cc766465(WS.10).aspx if you look towards the bottom it says exactly what you want to do.
     
    Last edited: 12 Mar 2012
  5. deathtaker27

    deathtaker27 Modder

    Joined:
    17 Apr 2010
    Posts:
    2,238
    Likes Received:
    186
    I guess you could use powershell, but thats a different thing all together
     
  6. Margo Baggins

    Margo Baggins I'm good at Soldering Super Moderator

    Joined:
    28 May 2010
    Posts:
    5,649
    Likes Received:
    268
    its so much harder using powershell! I dont think its a very good idea. Its only viable using powershell becuase it sits ontop of .net. I don't think it represents a very elegant solution.
     
    MonkeyBoss likes this.
  7. Atomic

    Atomic Gerwaff

    Joined:
    6 May 2002
    Posts:
    9,646
    Likes Received:
    94
    You do know that's not a secure way of wiping a disk.

    All the data will still be recoverable because a 'quick' format doesn't physically overwrite any data it just sets the partition table to say it's all blank.
     
    MonkeyBoss likes this.
  8. MonkeyBoss

    MonkeyBoss What's a Dremel?

    Joined:
    24 Jan 2012
    Posts:
    162
    Likes Received:
    11
    we got a pretty got solution for wiping drives, this is a seperate thing, thanks for the info guys, will have a go at it later

    +rep
     

Share This Page