Sign in to follow this  
Followers 0
d4rk

Format a drive ...

23 posts in this topic

2 every1,

i used this code to format my D drive :

RunWait(@ComSpec & " /c " & 'format d:', "", @SW_MAXIMIZE)

but it asked for the current volume label ?

some body know why ?


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites



Try

RunWait(@ComSpec & " /c " & 'format d: /V:test', "", @SW_MAXIMIZE)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Yoh, thanks but it still it :) ...

i've try this one :

$a=DriveGetLabel("d:\")
RunWait(@ComSpec & " /c " & 'format d:', "", @SW_MAXIMIZE)
send($a)
send("y")
send("{Enter}")

but it doesn't send the volume label ($a) to the command prompt

am i missing something ?


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

:), sorry but it doesn't work ... , the first line i see in command prompt is "the type of the file system is NTFS"

does it make all this ?

...

by the way, please show me how to put a command into command prompt , send() seems impossible ?

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

try

RunWait(@ComSpec & " /c " & 'echo y | format d: /V:test /X', "", @SW_MAXIMIZE)

Share this post


Link to post
Share on other sites

:), sorry but it doesn't work ... , the first line i see in command prompt is "the type of the file system is NTFS"

does it make all this ?

It would need enough information to do it unattended. So now this is telling it a filesystem to use. Use format /? to get available switches to use.

RunWait(@ComSpec & " /c " & 'format d: /FS:NTFS /V:test /X', "", @SW_MAXIMIZE)

by the way, please show me how to put a command into command prompt , send() seems impossible ?

If you wanted to handle it through it's prompts then you would need to use Run() with StdOutRead() to read the out stream and use StdInWrite() to respond to the prompts with the answers. I do not have a drive to test a format so I am reluctant to create a example for this task but you have enough information to look into it yourself now.

Share this post


Link to post
Share on other sites

God :)

is it needed to use StdOutRead() before using StdInWrite() ?

i'm going to use only StdInWrite() for responding ?


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

God :)

is it needed to use StdOutRead() before using StdInWrite() ?

i'm going to use only StdInWrite() for responding ?

If you can expect the output given then you can just use StdInWrite() to handle the prompt. If whims' idea works then that maybe easier to use. Some testing will give you a good method. ;)

Share this post


Link to post
Share on other sites

If you can expect the output given then you can just use StdInWrite() to handle the prompt. If whims' idea works then that maybe easier to use. Some testing will give you a good method. :)

Yes, whims's idea works but it can't run as my aim, sorry but plz tell me why this can't put an 2 char to the command promt ?

#NoTrayIcon
#include <Constants.au3>
$omg=RunWait(@ComSpec & " /k " & 'format d:', "", @SW_MAXIMIZE,$STDIN_CHILD + $STDOUT_CHILD)
StdInWrite($omg,"2" & @CRLF))

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Use Run(), not RunWait().

Share this post


Link to post
Share on other sites

Use Run(), not RunWait().

run() make the cmd window and dissappear immediatly

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

You will need to keep the script working on the task until you can process the StdInWrite to insure it succeeds. So use StdOutRead to halt things a little until you use StdInWrite.

Example

#NoTrayIcon
#include <Constants.au3>
$omg = Run(@ComSpec & " /k " & 'format d:', "", @SW_MAXIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
While 1
    $data &= StdOutRead($omg)
    If @error Then ExitLoop
    If StringInStr($data, 'Format or whatever the prompt asks?') Then
        StdInWrite($omg,"2" & @CRLF)
        ExitLoop
    EndIf
WEnd
ProcessWaitClose($omg)oÝ÷ Ù*&zئz̨ºf²j[(ç¶Ö§{ bëh¶©®+jfÞ~Þ±éÝxjÖ¬¢'çyç^vëjëh×6StdInWrite($omg, @CRLF)
;or even just a @CR
StdInWrite($omg, @CR)

It is a pain sometimes to get it working correct but it can usually be done.

Share this post


Link to post
Share on other sites

Also, it just struck me that OP might be confused because he doesn't see

any output in cmd window due to StdOut also being redirected.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Runwait(@ComSpec & " /k "& "format d: /FS:NTFS /q /v:Volume /y",@WindowsDir,@SW_SHOW)
winclose("C:\WINDOWS\system32\cmd.exe");Windows XP
winclose("Administrator: C:\Windows\system32\cmd.exe");Vista

Auto format, ask no questions

Edited by Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Runwait(@ComSpec & " /k "& "format d: /FS:NTFS /q /v:Volume /y",@WindowsDir,@SW_SHOW)
winclose("C:\WINDOWS\system32\cmd.exe");Windows XP
winclose("Administrator: C:\Windows\system32\cmd.exe");Vista

Auto format, ask no questions

Thanks every1, it's great to be helped by all of you, Kerros's code works and it seem easy for me ... but also i'll try it with

StdOutRead() and StdInWrite()

i have a last question on this topic, that with the /q (quick format), can it use when there're some bad sector on the drive ?

thx


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

Runwait(@ComSpec & " /k "& "format d: /FS:NTFS /q /v:Volume /y",@WindowsDir,@SW_SHOW)
winclose("C:\WINDOWS\system32\cmd.exe");Windows XP
winclose("Administrator: C:\Windows\system32\cmd.exe");Vista

Auto format, ask no questions

Thanks every1, it's great to be helped by all of you, Kerros's code works and it seem easy for me ... but also i'll try it with

StdOutRead() and StdInWrite()

i have a last question on this topic, that with the /q (quick format), can it work when there're some bad sector on the drive ?

thx


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

A quick format should complete correctly on a drive with a bad sector. A full format would be better, and a full write(think low level format) of the drive would be best as that way the drive would have a chance to reallocate the bad sectors out to spares.

A good free program to do a what people call a low level format would be Kill Disk. http://www.killdisk.com/downloadfree.htm


Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites

Hi

You can also append a &exit at the end of the command. This way, you can have multipe commands on one line.

Like:

Runwait(@ComSpec & " /k "& "format "&$drive&" /FS:FAT32 /v:USB_Boot /x /y&exit",@WindowsDir,@SW_SHOW)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Better: take /c instead of /k then the cmd window closes if the command is finished

Runwait(@ComSpec & " /c "& "format "&$drive&" /FS:FAT32 /v:USB_Boot /x /y",@WindowsDir,@SW_SHOW)
Edited by Orca75

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  
Followers 0