ReDFlaG Posted September 30, 2006 Share Posted September 30, 2006 (edited) hello, i'm coding a GUI for the chkdsk.exe utility. i'm launching the dos tools in an hidden windows and grab the stdout in a var. the issue is that sometimes chkdsk ask (y/n) (in case it has to reboot to do it stuff). how can i send it y or n? $foo = Run(@SystemDir &'\chkdsk.exe ' &$numpart& ' /F', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error Then ExitLoop If StringInStr($line,"(O/N)",0) Then $temp=MsgBox(1+48,"chkdsk","Chkdsk need to unmount the volume, do you want it to check the volume at the next reboot?") If $temp = 1 Then ????? i started thinking about a StdinWrite($foo,"o" & @CR) but it's not the solution. Can someone help? thanks Edited September 30, 2006 by ReDFlaG Link to comment Share on other sites More sharing options...
Nezoic Posted September 30, 2006 Share Posted September 30, 2006 hello, i'm coding a GUI for the chkdsk.exe utility. i'm launching the dos tools in an hidden windows and grab the stdout in a var. the issue is that sometimes chkdsk ask (y/n) (in case it has to reboot to do it stuff). how can i send it y or n? $foo = Run(@SystemDir &'\chkdsk.exe ' &$numpart& ' /F', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $line = StdoutRead($foo) If @error Then ExitLoop If StringInStr($line,"(O/N)",0) Then $temp=MsgBox(1+48,"chkdsk","Chkdsk need to unmount the volume, do you want it to check the volume at the next reboot?") If $temp = 1 Then ????? i started thinking about a StdinWrite($foo,"o" & @CR) but it's not the solution. Can someone help? thanks Write the chkdsk data to a file, read the file and find the line with the [Y/N] i.e. CHKDSK.EXE > TMP.TXT Might be a better way with Autoit but this way should work just the same. Link to comment Share on other sites More sharing options...
AceLoc Posted September 30, 2006 Share Posted September 30, 2006 (edited) $foo = Run(@SystemDir & '\chkdsk.exe ' & $numpart & ' /F', '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $line = StdoutRead ($foo) If @error Then ExitLoop If StringInStr($line, "(O/N)", 0) Then $temp = MsgBox(1 + 48, "chkdsk", "Chkdsk need to unmount the volume, do you want it to check the volume at the next reboot?") If $temp = 1 Then Sleep(1000) $a = "chkdsk.exe" ControlSend($a, "", "", "Y"); if you wanna sent "Y" ControlSend($a, "", "", "N"); if you wanna sent "N" Should work ! Edited September 30, 2006 by aceloc [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
ReDFlaG Posted September 30, 2006 Author Share Posted September 30, 2006 Thanks for your help, but it's not working. The autoit help file says "ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send " Annother idea? Link to comment Share on other sites More sharing options...
AceLoc Posted September 30, 2006 Share Posted September 30, 2006 Thanks for your help, but it's not working. The autoit help file says "ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send " Annother idea? $a = "chkdsk.exe" ControlSend($a, "", "", "Y"); if you wanna sent "Y" ControlSend($a, "", "", "N"); if you wanna sent "N" the problem there is that the Control ID is still empty.. you need to look that for yourself. (i dont know sure if ddos got a Control ID though.) it works like this: ControlSend("title", "text", "control ID", "Whatever-you-wanna-sent") Goodlucky [quote name='AceLoc']I gots new sunglasses there cool.[/quote] Link to comment Share on other sites More sharing options...
Danny35d Posted September 30, 2006 Share Posted September 30, 2006 Thanks for your help, but it's not working. The autoit help file says "ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send " Annother idea? You can try it in a different approch... 1) Msgbox 2) Create an answer file 3) run command line chkdsk.exe $volume $switches < Answer.file 4) delete answer file Example: $temp = MsgBox(1 + 48, "chkdsk", "Chkdsk may need to unmount the volume, do you want it to check the volume at the next reboot?") If $temp = 1 Then FileWriteLine(@TempDir & '\Answer.txt', 'y') If $temp = 2 Then FileWriteLine(@TempDir & '\Answer.txt', 'n') $numpart = 'c:' RunWait(@ComSpec & ' /c chkdsk.exe ' & $numpart & ' /F < ' & @TempDir & '\Answer.txt', '', @SW_HIDE) FileDelete(@TempDir & '\Answer.txt') Hope this help you or least give an idea... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
ReDFlaG Posted September 30, 2006 Author Share Posted September 30, 2006 thanks again i will try those solutions. a small question: when you right click on a drive and choose propreties, then tools, you can do a "check now". it's fully graphical, and it ask if you want to reboot or not. i'm not seeing any "chkdsk.exe" process into the task manager list, so i was wondering how does windows proceed to check the disk in that case. some one has an hint? Link to comment Share on other sites More sharing options...
creeping Posted October 1, 2006 Share Posted October 1, 2006 (edited) This works for me #include <Constants.au3> $PID = Run("chkdsk /f c:", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($PID) If @error Then ExitLoop If StringInStr($line, "(Y/N)") Then StdinWrite($PID, "Y" & @CRLF) StdinWrite($PID) ExitLoop EndIf Wend Not quite sure what you mean, so I will just ramble some babble at you. The OS can not check the disk with the /f switch if its in use. So if you have a D: drive you can do a chkdsk without rebooting. But if you were to open a folder on D: drive then try to do chkdsk /f d: it would prompt you to do it on the next reboot like C: drive cause its in use. You will not see chkdsk in the process list waiting to check C: drive, it flags the drive as dirty. Whe the OS boots up it will check any disks with that flag set. Edited October 1, 2006 by creeping Link to comment Share on other sites More sharing options...
ReDFlaG Posted October 15, 2006 Author Share Posted October 15, 2006 thanks a lot to all of you, it's working perfectly. Link to comment Share on other sites More sharing options...
themush1326 Posted January 30, 2007 Share Posted January 30, 2007 thanks a lot to all of you, it's working perfectly. Can you post you final code for this? 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