dobbelina Posted September 5, 2006 Share Posted September 5, 2006 (edited) Hi ! I'm a total newbie at this . 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 Edited September 5, 2006 by dobbelina Link to comment Share on other sites More sharing options...
BigDod Posted September 5, 2006 Share Posted September 5, 2006 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. 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 Link to comment Share on other sites More sharing options...
AceLoc Posted September 5, 2006 Share Posted September 5, 2006 (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 September 5, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
dobbelina Posted September 6, 2006 Author Share Posted September 6, 2006 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 Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 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] Link to comment Share on other sites More sharing options...
dobbelina Posted September 6, 2006 Author Share Posted September 6, 2006 (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 September 6, 2006 by dobbelina Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 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] Link to comment Share on other sites More sharing options...
GoogleDude Posted September 6, 2006 Share Posted September 6, 2006 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 Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 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>GoogleDudebut that dont work hided right? :/ [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
GoogleDude Posted September 6, 2006 Share Posted September 6, 2006 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. GoogleDude Link to comment Share on other sites More sharing options...
AceLoc Posted September 6, 2006 Share Posted September 6, 2006 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. GoogleDudebut look above the $handle script should work aswell. [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
GoogleDude Posted September 6, 2006 Share Posted September 6, 2006 (edited) Sorry im new to autoit so if you say it sould work then im sure it will. Edited September 6, 2006 by GoogleDude Link to comment Share on other sites More sharing options...
dobbelina Posted September 7, 2006 Author Share Posted September 7, 2006 (edited) Ho ho ha ha I finally got it to work ! (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% hiddenOpt ("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^çÇè®fw2ëA LDzÛ÷(uæ(ºÇr¦jwi®©µ©pk+²K¢»azv¦{÷k÷¥i·¥¡ûaz«¶+b¢{h~æjØßÛººÞÙÚæÞ~Þ×(ا¹ë-¢Ø^ªê-aë(¬Ú)®©¶«¨´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 waywith 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) Edited September 7, 2006 by dobbelina Link to comment Share on other sites More sharing options...
AceLoc Posted September 7, 2006 Share Posted September 7, 2006 (edited) Ho ho ha ha I finally got it to work ! (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% hiddenOpt ("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^çÇè®fw2ëA LDzÛ÷(uæ(ºÇr¦jwi®©µ©pk+²K¢»azv¦{÷k÷¥i·¥¡ûaz«¶+b¢{h~æjØßÛººÞÙÚæÞ~Þ×(ا¹ë-¢Ø^ªê-aë(¬Ú)®©¶«¨´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 September 7, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
dobbelina Posted September 17, 2006 Author Share Posted September 17, 2006 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 Link to comment Share on other sites More sharing options...
JRSmile Posted February 16, 2007 Share Posted February 16, 2007 (edited) öhhm what about this $pid = Run(@ComSpec & " /c " & 'echo. | format D: /v:Disk2 /fs:fat32 /q /x', "",@SW_HIDE, $STDIN_CHILD) Edited February 16, 2007 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:-) Link to comment Share on other sites More sharing options...
microsoft Posted January 22, 2009 Share Posted January 22, 2009 THANKS 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