Sign in to follow this  
Followers 0
dobbelina

Format D drive hidden

17 posts in this topic

#1 ·  Posted (edited)

Hi !

I'm a total newbie at this :nuke:.

What I want to do is run a commandline to format the D drive with hidden windows, but can't get it to work ?

This works(not hidden):

DriveSetLabel("D:\", "Y")
Run(@ComSpec & " /c " & 'format D: /v:mydrive /q /x', "")
WinWaitActive("")
Send("Y{ENTER}Y{ENTER}")

Why is this, and what do I do to remedy it so the command window doesn't show up ?

I only squezzed that @SW_HIDE in after the 2 commas as it seems to be the right place for it.

Help please :P

Edited by dobbelina

Share this post


Link to post
Share on other sites



This line

Send("Y{ENTER}Y{ENTER}")

cant work with a hidden window as there is nothing to send to. You may want to investigate StdinWrite and StdoutRead.



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

#3 ·  Posted (edited)

probably you can also use Controlsend which works like this:

ControlSend("title", "text", "controlID", "string", Flag)

to find that information like the Title ControlID etc use the "AutoIt Window Info" tool.

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

probably you can also use Controlsend which works like this:

ControlSend("title", "text", "controlID", "string", Flag)

This doesn't work, but if you remove the "@SW_HIDE" it does.(unhidden offcourse).

I guess the only thing to get this to work is to use that "StdinWrite" and "StdoutRead" somehow..

If somebody could give me a hint i'd be very gratefull, those two functions really gimme a headache :P

Share this post


Link to post
Share on other sites

Thanks for the tip, unfortunately it doesn't work when using "@SW_HIDE".

DriveSetLabel("D:\", "Y")
Run(@ComSpec & " /c " & 'format D: /v:mydrive /fs:fat32 /q /x', "",@SW_HIDE)
WinWaitActive("")
ControlSend('', '', '', 'Y{ENTER}')
ControlSend('', '', '', 'Y{ENTER}')oÝ÷ Ù8b±Ú²}ý·
+»­ü¨º·¦¢÷­ê®¢ÔĪê-×hz˧']zz}Ê.®Ç笲Ø^¢yr¶§Ú zÛaËhÂäËhºÇ­«jºRµØ§Z¸­z«¨µ©Ýªê-J×hºÔ^iÚ®¢Û(èhÀì¢g¡Ü¢é]+Þæ¡{bß×[z÷«Ê
Úµçî[a¢Ç­ÂîËb¢{+y©eʦæ¡y§Zr±þ«¨µì¨¹ªÞv§+p®àjÌX­²X¤xLZ^jëh×6ControlSend("C:\WINDOWS\System32\cmd.exe", "Y{ENTER}Y{ENTER}", "controlID", "string", 1)

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry, that doesn't work at all.

Where you put the "Y{ENTER}Y{ENTER}" is for "The text of the window to access."

The 4 position is for the strings.(as I understand it, correct me if i'm wrong)

My example works, but not hidden.

As I know what the command prompt is going to return, I wouldn't need to use "StdoutRead".

Only "StdinWrite" somehow.

My brain has already started to melt !

If somebody could piece it together, slightly at least, i'd be a happy camper.

Edited by dobbelina

Share this post


Link to post
Share on other sites

okay this is my last attempt to help you

AutoItSetOption("WinTitleMatchMode", PARAM)

; Get the handle of the CMD window
$handle = WinGetHandle("classname=THE CLASSNAME", "")
If @error Then
    MsgBox(4096, "Error", "Could not find correct window.")
    exit
Else
$i = 0
Do
    
    


;    MsgBox(4096, "success", "The window handle is " & $handle)
   ; Send some text directly to this window's edit control
   ;ControlClick("handle=" & $handle, "", "", "left")
    Opt("SendKeyDelay",35)
    ControlSend("handle=" & $handle, "", "", "Y")
    ControlSend("handle=" & $handle, "", "", "{ENTER}")
    ControlSend("handle=" & $handle, "", "", "Y")
    ControlSend("handle=" & $handle, "", "", "{ENTER}")  
    $i = $i + 1  
    Until $i = 1

EndIf

exit

If you still cant make it work.. then im sorry and cant help you.


[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

I remember in the dos days you could use a |y to auto format a drive without being prompted, not sure if it still works under xp/2003.

for example: format d: |y <ENTER>

GoogleDude

Share this post


Link to post
Share on other sites

I remember in the dos days you could use a |y to auto format a drive without being prompted, not sure if it still works under xp/2003.

for example: format d: |y <ENTER>

GoogleDude

but that dont work hided right? :/

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

it should. I have not tried it though. but I dont see why not. i just remember that as soon as you type the command line and hit ENTER it would auto format with out a warning at all, but that was a long time ago under dos 4.x or 5.x i think or maybe even 6.x. :P

GoogleDude

Share this post


Link to post
Share on other sites

it should. I have not tried it though. but I dont see why not. i just remember that as soon as you type the command line and hit ENTER it would auto format with out a warning at all, but that was a long time ago under dos 4.x or 5.x i think or maybe even 6.x. :P

GoogleDude

but look above the $handle script should work aswell.

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Sorry im new to autoit so if you say it sould work then im sure it will. :P

Edited by GoogleDude

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ho ho ha ha I finally got it to work ! :P(Thanks for everybodys Help)

I forgot to put in the titlename of the window, that's why it couldn't find it when hidden.

This works 100% hidden

Opt ("TrayIconHide",1)  
Opt("WinWaitDelay", 1)
Opt("WinTitleMatchMode",2)
DriveSetLabel("D:\", "Y")
Run(@ComSpec & " /c " & 'format D: /v:mydrive /fs:fat32 /q /x', "",@SW_HIDE)
ControlSend("cmd.exe", "", "", "Y{ENTER}Y{ENTER}")oÝ÷ ØZ½é÷öÛkçF¢%yÛ{l{¦¦WºÒ-)ä×hzÉ÷öÜ(®G(uçè­ìZ^çÇè®f­w2ëA
LDzÛ÷((ºÇr¦jwi®©µ©pk+²K¢»azv¦{÷k÷¥i·¥¡ûaz«¶+{h~æjØ­ßÛººÞÙÚæÞ~Þ×(ا¹ë-¢Ø^ªê-(¬Ú)®©¶«¨´z0z÷«ûaxö«¶+b¢whzÉ÷öØZ½æ§jg©äÜ"X(¶az«¨µ¬¢³h¦º&¦Ú®¢×b­ç-$ájÝý²Ø^­æ¬¢|!ȵ§k÷¥i·¥mçè­çè®f­¶)àjëh×6DriveSetLabel("D:\", "Y")

Now the partition has the same name as the yes command, hence it will format either way

with a nice "Y{ENTER}Y{ENTER}" :)

Hmm, wouldn't it be cool if I could have some window showing up instead, that says "Formatting etc"

now that the hideous command prompt has been taken care off.

Is now a good time to use a "while statement" ?

(I'm such a beginner) :nuke:

Edited by dobbelina

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Ho ho ha ha I finally got it to work ! :P(Thanks for everybodys Help)

I forgot to put in the titlename of the window, that's why it couldn't find it when hidden.

This works 100% hidden

Opt ("TrayIconHide",1)  
Opt("WinWaitDelay", 1)
Opt("WinTitleMatchMode",2)
DriveSetLabel("D:\", "Y")
Run(@ComSpec & " /c " & 'format D: /v:mydrive /fs:fat32 /q /x', "",@SW_HIDE)
ControlSend("cmd.exe", "", "", "Y{ENTER}Y{ENTER}")oÝ÷ ØZ½é÷öÛkçF¢%yÛ{l{¦¦WºÒ-)ä×hzÉ÷öÜ(®G(uçè­ìZ^çÇè®f­w2ëA
LDzÛ÷((ºÇr¦jwi®©µ©pk+²K¢»azv¦{÷k÷¥i·¥¡ûaz«¶+{h~æjØ­ßÛººÞÙÚæÞ~Þ×(ا¹ë-¢Ø^ªê-(¬Ú)®©¶«¨´z0z÷«ûaxö«¶+b¢whzÉ÷öØZ½æ§jg©äÜ"X(¶az«¨µ¬¢³h¦º&¦Ú®¢×b­ç-$ájÝý²Ø^­æ¬¢|!ȵ§k÷¥i·¥mçè­çè®f­¶)àjëh×6DriveSetLabel("D:\", "Y")oÝ÷ ØÚ0¶©j»b¶*'«-ëéÚ欶²zÇ(f§v§qè­Â)e~æj×¢¶«Á¬°ØZ'ªê-`CS51ªê-i°¢é]mÖÞr%ò¢é]«Þ²Â)Ý£!£§êbË^iÛajÛÊÊ®¢Ñh®f­¶)àz×*ºg£ajÛazz¬r¦jwi®©¶¬m秵©Æ«zß"ÉèÁ¨(¡ÛbëhºÇªê-Â¥zËZµéÚ®¢Ò7ök.rz§êð+-ïêº^jëh×6Opt("TrayIconHide",1)   
Opt("WinWaitDelay", 1)
Opt("WinTitleMatchMode", 2)
DriveSetLabel("D:\", "Y")
Run(@ComSpec & " /c " & 'format D: /v:mydrive /fs:fat32 /q /x', "",@SW_HIDE)
ControlSend("cmd.exe", "", "", "Y{ENTER}Y{ENTER}")
sleep(4000); dont know how long.
Msgbox(0, "NOTE", "Your D:\ is formatting Hided, Isnt that great!?")oÝ÷ Ù·ßÛÊ¢é]j[(i×m+"Ƭz'íè.Ë¥kyº(¶¬r©º×«ßÖÞ~ÞÛ¢¹¶×jëh×6RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run', 'YourApp', 'REG_SZ', 'c:\PathTo\YourApp.exe')

change YourApp and c:\PathTo\YourApp.exe

Edited by aceloc

[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

Just for your info, all the stuff above (That I thought worked) doesn't.

You see, It works when testing in "Normal Windows", but not when run from "RunOnceEx".

(Using it as an option in WPI, (Windows Post Install Wizard).

Have no idea why, but it doesn't matter cause i've finally got it to work using "StdinWrite" :)

Controlsend is a bad idea to use with command promts, cause it works kinda random..

To be honest, I don't really understand this "StdinWrite" stuff much, but after alot of tinkering in VMware

I got it to work, (fingers crossed).

Here's the "correct" version if anybody wants it.

It will Automatically Format the D,E and F if they exist, (except C: offcourse).

In this configuration it will format as Fat32, but if you want NTFS simply change the "fs:fat32" to "fs:ntfs".

#include <Constants.au3>
SplashTextOn("","Formatting Drive/s" & @CRLF & "Please Wait..","300","100","-1","-1",33,"Courier New","20","700")
Sleep (1000)
$var = DriveGetType( "D:\" )

If $var = "Fixed" Then 
DriveSetLabel("D:\", "Y")
$pid = Run(@ComSpec & " /c " & 'format D: /v:Disk2 /fs:fat32 /q /x', "",@SW_HIDE, $STDIN_CHILD)
StdinWrite($pid, "Y" & @CRLF & "Y" & @CRLF)
ProcessWaitClose($pid)
EndIf

$var2 = DriveGetType( "E:\" )

If $var2 = "Fixed" Then 
DriveSetLabel("E:\", "Y")
$pid = Run(@ComSpec & " /c " & 'format E: /v:Disk3 /fs:fat32 /q /x', "",@SW_HIDE, $STDIN_CHILD)
StdinWrite($pid, "Y" & @CRLF & "Y" & @CRLF)
ProcessWaitClose($pid)
EndIf

$var3 = DriveGetType( "F:\" )

If $var3 = "Fixed" Then 
DriveSetLabel("F:\", "Y")
$pid = Run(@ComSpec & " /c " & 'format F: /v:Disk4 /fs:fat32 /q /x', "",@SW_HIDE, $STDIN_CHILD)
StdinWrite($pid, "Y" & @CRLF & "Y" & @CRLF)
ProcessWaitClose($pid)
EndIf
SplashTextOn("","Formatting Complete","350","100","-1","-1",33,"Courier New","20","700")
Sleep (3000)
Exit

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

öhhm what about this

$pid = Run(@ComSpec & " /c " & 'echo. | format D: /v:Disk2 /fs:fat32 /q /x', "",@SW_HIDE, $STDIN_CHILD)

Edited by JRSmile

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

THANKS

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