Simplify iT Posted April 14, 2006 Posted April 14, 2006 I am trying to create an automated convertion function for converting fat/fat32 to ntfs is the convert.exe command that is part of windows. The problem that i am having is that when a volume name is present, user input is required and this is the problem as i want a total hands free solution.The command that needs to be run is: convert f: /fs:ntfs from the command prompt (cmd.exe) the following is presented when a volume label is present:The type of the file system is FAT32.Enter current volume label for drive F:Now there are 2 options that i can see; 1. capture the volume label, then remove the volume (delete) label (this will allow the convert command to run without user input), and the add the captured volume label back after the convert command has finished. 2. Automatically send the Volume label to the convert command when prompted. e.g.The type of the file system is FAT32.Enter current volume label for drive F: Volume NameIdeally the script will check each disk volume to see if it is currently NTFS, and then if not convert it using the above command format...Being new to AutoIt i really need some help and advise on how to do this... Any and all suggestions would be very appreciated Cheers,Darren
NightGaunt Posted April 14, 2006 Posted April 14, 2006 Greetings Program, Ok first of all don't worry so much about trying to capture this stuff from the command line. Check the Help file for two commands that will help you. 1) DriveGetLabel 2) DriveGetFileSystem Those will give you the answers to both of your questions. If you just set the label to a variable you can parse it in to the convert command fairly easily. "I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
Simplify iT Posted April 14, 2006 Author Posted April 14, 2006 Greetings Program, Ok first of all don't worry so much about trying to capture this stuff from the command line.Check the Help file for two commands that will help you.1) DriveGetLabel2) DriveGetFileSystem Those will give you the answers to both of your questions. If you just set the label to a variable you can parse it in to the convert command fairly easily.Thankyou NightGuant,Yes i have found both of those commands, the biggest problem i have is parse it the prompt for the volume name..
NightGaunt Posted April 14, 2006 Posted April 14, 2006 Given the delay time for executing this command it should be extremly simple to just sleep right to it. 1) Check the Run command for details on how to get DOS executions to function properly, if you have an issue it may be releated to RunWait(@ComSpec & " /c " & 'commandName'). 2) Once you are done with that piece it should be simple. Just delay the command with a sleep, set your new box as the active window and make Auto-it type in the information. "I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
Simucal Posted April 14, 2006 Posted April 14, 2006 (edited) I think this might be what you are asking for. expandcollapse popup; GUI Example originally written by DaveF, modified by Simucal #include <GuiConstants.au3> GuiCreate("Auto Convert", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $eOutput = GuiCtrlCreateEdit("", 0, 10, 423, 260, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) $bExit = GuiCtrlCreateButton("Exit", 340, 285, 60, 20) GuiSetState() ; Run child process and provide console i/o for it. ; Parameter of 2 = provide standard output If DriveGetFileSystem("f:\") <> "NTFS" Then $ourProcess = Run("convert f: /fs:ntfs", @SystemDir, @SW_HIDE, 3) While 1 If $ourProcess Then ; Calling StdoutRead like this returns the characters waiting to be read $charsWaiting = StdoutRead($ourProcess, 0 , 1) If @error = -1 Then $ourProcess = 0 MsgBox(0, "App Exited", "Process has exited...") ContinueLoop EndIf If $charsWaiting Then $currentRead = StdoutRead($ourProcess) GUICtrlSetData($eOutput, $currentRead, 1) If StringInStr($currentRead, "Enter current volume label for drive") <> 0 Then StdinWrite($ourProcess, DriveGetLabel("f:\") & @CRLF) ExitLoop EndIf EndIf EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $bExit ExitLoop Case Else ;;; EndSelect WEnd Else MsgBox(0,"Error","Drive filesystem is already NTFS!") EndIf Exit Edited April 14, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Simplify iT Posted April 14, 2006 Author Posted April 14, 2006 If you tell me how the Volume name is determined I can write this for you really fast before class.What do you want the volume name to be? How is it determined?I wouldnt based this on delays, I would simply capture the stdout of the convert command, and trigger on whatever your appropriate messages are.Hi and thanks for your help. The volume name could be anything - it is the actual name of the volume that was enter when it was formated... so basically the only way to make sure it is correct is to query the volume name... the other thing that needs to be considered is that if there is no volume label, there is no prompt for further input other than the actually command line that launches it.
Simucal Posted April 14, 2006 Posted April 14, 2006 (edited) Let me know how it does, I wasnt able to test it. It requires BETA to be ran. Edited April 14, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Simplify iT Posted April 14, 2006 Author Posted April 14, 2006 Let me know how it does, I wasnt able to test it. It requires BETA to be ran.Thankyou Simucal - i downloaded the beta and did a test - it seemed to work once, and then i did a further tested by reformating the drive again back to fat32 and tried it again and it didn't work the second time.
Simucal Posted April 14, 2006 Posted April 14, 2006 Can you tell me exactly what it is doing? It is hard to debug because I cant test it here on my machine. AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Simucal Posted April 14, 2006 Posted April 14, 2006 Alright, fixed the bug where it would close sometimes. Also added the functionality you wanted to where it would check all the fixed drives on the system excluding C: to see if they were NTFS and if not it would convert them one by one. I have no means of testing this so let me know how it goes: expandcollapse popup#include <GuiConstants.au3> #include <array.au3> GuiCreate("Auto Convert", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $eOutput = GuiCtrlCreateEdit("", 0, 10, 423, 260, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GuiSetState() $SystemDrives = DriveGetDrive("Fixed") _ArraySort($SystemDrives, 0, 1) $DriveC = _ArrayBinarySearch ($SystemDrives, "c:",1) If $DriveC <> "" Then _ArrayDelete($SystemDrives,$DriveC) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf For $i = 1 to (UBound($SystemDrives)-1) If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then _ArrayDelete($SystemDrives, $i) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf Next If $SystemDrives[0] > 0 Then GUICtrlSetData($eOutput,"The following drives on the system need to be converted to NTFS: " & _ArrayToString($SystemDrives, ",",1)&@CRLF, 1) For $i = 1 To $SystemDrives[0] GUICtrlSetData($eOutput,"Starting to convert drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) $ourProcess = Run("convert" & $SystemDrives[$i] & "/fs:ntfs /x", @SystemDir, @SW_HIDE, 3) While 1 If $ourProcess Then $charsWaiting = StdoutRead($ourProcess, 0 , 1) If @error = -1 Then $ourProcess = 0 GUICtrlSetData($eOutput,"Finished converting drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) ExitLoop EndIf If $charsWaiting Then $currentRead = StdoutRead($ourProcess) GUICtrlSetData($eOutput, $currentRead, 1) If StringInStr($currentRead, "Enter current volume label for drive") <> 0 Then StdinWrite($ourProcess, DriveGetLabel($SystemDrives[$i]&"\") & @CRLF) EndIf EndIf EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Next GUICtrlSetData($eOutput,"Auto Convert is finished converting all non-ntfs drives!"& @CRLF, 1) Else MsgBox(0,"Error", "No other drives on the system need to be converted to NTFS!") EndIf Exit AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Simplify iT Posted April 15, 2006 Author Posted April 15, 2006 Alright, fixed the bug where it would close sometimes. Also added the functionality you wanted to where it would check all the fixed drives on the system excluding C: to see if they were NTFS and if not it would convert them one by one. I have no means of testing this so let me know how it goes: expandcollapse popup#include <GuiConstants.au3> #include <array.au3> GuiCreate("Auto Convert", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $eOutput = GuiCtrlCreateEdit("", 0, 10, 423, 260, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GuiSetState() $SystemDrives = DriveGetDrive("Fixed") _ArraySort($SystemDrives, 0, 1) $DriveC = _ArrayBinarySearch ($SystemDrives, "c:",1) If $DriveC <> "" Then _ArrayDelete($SystemDrives,$DriveC) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf For $i = 1 to (UBound($SystemDrives)-1) If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then _ArrayDelete($SystemDrives, $i) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf Next If $SystemDrives[0] > 0 Then GUICtrlSetData($eOutput,"The following drives on the system need to be converted to NTFS: " & _ArrayToString($SystemDrives, ",",1)&@CRLF, 1) For $i = 1 To $SystemDrives[0] GUICtrlSetData($eOutput,"Starting to convert drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) $ourProcess = Run("convert" & $SystemDrives[$i] & "/fs:ntfs /x", @SystemDir, @SW_HIDE, 3) While 1 If $ourProcess Then $charsWaiting = StdoutRead($ourProcess, 0 , 1) If @error = -1 Then $ourProcess = 0 GUICtrlSetData($eOutput,"Finished converting drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) ExitLoop EndIf If $charsWaiting Then $currentRead = StdoutRead($ourProcess) GUICtrlSetData($eOutput, $currentRead, 1) If StringInStr($currentRead, "Enter current volume label for drive") <> 0 Then StdinWrite($ourProcess, DriveGetLabel($SystemDrives[$i]&"\") & @CRLF) EndIf EndIf EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Next GUICtrlSetData($eOutput,"Auto Convert is finished converting all non-ntfs drives!"& @CRLF, 1) Else MsgBox(0,"Error", "No other drives on the system need to be converted to NTFS!") EndIf Exit Ok have tried some tests - when i load in scite and run it to test i get an error at line 29: test.au3 (29) : ==> Unknown function name.: $charsWaiting = StdoutRead($ourProcess, 0 , 1) $charsWaiting = ^ ERROR ->AutoIT3.exe ended.rc:1 When i run on any of the systems i get the following Autoit error dialogue box: Line 16 (path_to_file\test.au3): If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then If DriveGetFileSystem(^ERROR Error: Array varriable has incorrect number of subscripts or subscript dimension range exceeded. Hope this information is helpful. Darren
exodius Posted April 15, 2006 Posted April 15, 2006 Ok have tried some tests - when i load in scite and run it to test i get an error at line 29: test.au3 (29) : ==> Unknown function name.: $charsWaiting = StdoutRead($ourProcess, 0 , 1) $charsWaiting = ^ ERROR ->AutoIT3.exe ended.rc:1 When i run on any of the systems i get the following Autoit error dialogue box: Line 16 (path_to_file\test.au3): If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then If DriveGetFileSystem(^ERROR Error: Array varriable has incorrect number of subscripts or subscript dimension range exceeded. Hope this information is helpful. Darren The first error seems like you're not running SciTE with the Beta definitions.. You can switch it using the "Switch-Definitions" script in SciTE's Start Menu folder... The second one is because $SystemDrives, as an array, does not have as many elements as your for loop is calling.. A way to debug this would be to make a message box just prior to that part of the script to display the value of $SystemDrives[0] to see how many elements that array actually contains to see if something just isn't getting the right info.
Simplify iT Posted April 15, 2006 Author Posted April 15, 2006 (edited) The first error seems like you're not running SciTE with the Beta definitions.. You can switch it using the "Switch-Definitions" script in SciTE's Start Menu folder...I have done this, however i still get the error... K:\convertNTFS.au3 (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If DriveGetFileSystem($SystemDrives[$i]&"\") = "NTFS" Then If DriveGetFileSystem(^ ERROR +>AutoIT3.exe ended.rc:0 Edited April 15, 2006 by Simplify iT
Simucal Posted April 15, 2006 Posted April 15, 2006 (edited) Alright, I have fixed my array errors, a few typos, and made it output more information to the editbox about what it is doing. I have also commented the code a little so you can have some idea of what is going on. Enjoy your auto-converter expandcollapse popup; Written by Simucal #include <GuiConstants.au3> #include <array.au3> GuiCreate("Auto Convert", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS); create the gui window $eOutput = GuiCtrlCreateEdit("", 0, 10, 423, 300, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GuiSetState() $SystemDrives = DriveGetDrive("Fixed"); store the string names of all the fixed drives on the system in $SystemDrives array _ArraySort($SystemDrives, 0, 1); arrays should be sorted before using binary search $DriveC = _ArrayBinarySearch ($SystemDrives, "c:",1); search to see if there is a C:\ drive If $DriveC <> "" Then; if there is, delete it from the array as it will already be NTFS _ArrayDelete($SystemDrives,$DriveC) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf For $ArraySize = UBound($SystemDrives) to 2 Step -1; this for loop then checks the remaining drives to see if they are NTFS or not, and modifies the array so only non-ntfs are left GUICtrlSetData($eOutput,"Checking filesystem of drive: " & $SystemDrives[$ArraySize - 1] & "\" & @CRLF, 1) If DriveGetFileSystem($SystemDrives[$ArraySize - 1]&"\") = "NTFS" Then GUICtrlSetData($eOutput," Drive: " & $SystemDrives[$ArraySize - 1] & "\" & " is already NTFS." & @CRLF, 1) _ArrayDelete($SystemDrives, ($ArraySize - 1)) $SystemDrives[0] = $SystemDrives[0] - 1 Else GUICtrlSetData($eOutput," Drive: " & $SystemDrives[$ArraySize - 1] & "\" & " needs to be converted." & @CRLF, 1) EndIf Next If $SystemDrives[0] > 0 Then GUICtrlSetData($eOutput,"The following drives on the system need to be converted to NTFS: " & _ArrayToString($SystemDrives, ",",1)&@CRLF, 1) For $i = 1 To $SystemDrives[0]; repeat the convert loop as many times as their are drives to be converted GUICtrlSetData($eOutput,"Starting to convert drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) $ourProcess = Run("convert " & $SystemDrives[$i] & "/fs:ntfs /x", @SystemDir, @SW_HIDE, 3); run convert with the array variable that holds the drive letter While 1 If $ourProcess Then $charsWaiting = StdoutRead($ourProcess, 0 , 1); capture the output of convert and store it into a variable If @error = -1 Then; If the convert has finished and exited, this will error, having it exit the while loop and check the for loop to see if there is another drive to be done. $ourProcess = 0 GUICtrlSetData($eOutput,"Finished converting drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) ExitLoop EndIf If $charsWaiting Then $currentRead = StdoutRead($ourProcess); take the captured characters and store them in the $currentread variable GUICtrlSetData($eOutput, $currentRead, 1); make it dump this to the GUI edit box If StringInStr($currentRead, "Enter current volume label for drive") <> 0 Then; if any of those characters have the string "Enter current volume label for drive" then StdinWrite($ourProcess, DriveGetLabel($SystemDrives[$i]&"\") & @CRLF); write the appropriate drive label to the program EndIf EndIf EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Next GUICtrlSetData($eOutput,"Auto Convert is finished converting all non-ntfs drives!"& @CRLF, 1) Else MsgBox(0,"Error", "No other drives on the system need to be converted to NTFS!") EndIf Exit Edited April 15, 2006 by Simucal AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Simplify iT Posted April 15, 2006 Author Posted April 15, 2006 Alright, I have fixed my array errors, a few typos, and made it output more information to the editbox about what it is doing. I have also commented the code a little so you can have some idea of what is going on. Enjoy your auto-converter expandcollapse popup; Written by Simucal #include <GuiConstants.au3> #include <array.au3> GuiCreate("Auto Convert", 425, 322,(@DesktopWidth-425)/2, (@DesktopHeight-362)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS); create the gui window $eOutput = GuiCtrlCreateEdit("", 0, 10, 423, 300, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY)) GuiSetState() $SystemDrives = DriveGetDrive("Fixed"); store the string names of all the fixed drives on the system in $SystemDrives array _ArraySort($SystemDrives, 0, 1); arrays should be sorted before using binary search $DriveC = _ArrayBinarySearch ($SystemDrives, "c:",1); search to see if there is a C:\ drive If $DriveC <> "" Then; if there is, delete it from the array as it will already be NTFS _ArrayDelete($SystemDrives,$DriveC) $SystemDrives[0] = $SystemDrives[0] - 1 EndIf For $ArraySize = UBound($SystemDrives) to 2 Step -1; this for loop then checks the remaining drives to see if they are NTFS or not, and modifies the array so only non-ntfs are left GUICtrlSetData($eOutput,"Checking filesystem of drive: " & $SystemDrives[$ArraySize - 1] & "\" & @CRLF, 1) If DriveGetFileSystem($SystemDrives[$ArraySize - 1]&"\") = "NTFS" Then GUICtrlSetData($eOutput," Drive: " & $SystemDrives[$ArraySize - 1] & "\" & " is already NTFS." & @CRLF, 1) _ArrayDelete($SystemDrives, ($ArraySize - 1)) $SystemDrives[0] = $SystemDrives[0] - 1 Else GUICtrlSetData($eOutput," Drive: " & $SystemDrives[$ArraySize - 1] & "\" & " needs to be converted." & @CRLF, 1) EndIf Next If $SystemDrives[0] > 0 Then GUICtrlSetData($eOutput,"The following drives on the system need to be converted to NTFS: " & _ArrayToString($SystemDrives, ",",1)&@CRLF, 1) For $i = 1 To $SystemDrives[0]; repeat the convert loop as many times as their are drives to be converted GUICtrlSetData($eOutput,"Starting to convert drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) $ourProcess = Run("convert " & $SystemDrives[$i] & "/fs:ntfs /x", @SystemDir, @SW_HIDE, 3); run convert with the array variable that holds the drive letter While 1 If $ourProcess Then $charsWaiting = StdoutRead($ourProcess, 0 , 1); capture the output of convert and store it into a variable If @error = -1 Then; If the convert has finished and exited, this will error, having it exit the while loop and check the for loop to see if there is another drive to be done. $ourProcess = 0 GUICtrlSetData($eOutput,"Finished converting drive: " & $SystemDrives[$i] & "\" & @CRLF, 1) ExitLoop EndIf If $charsWaiting Then $currentRead = StdoutRead($ourProcess); take the captured characters and store them in the $currentread variable GUICtrlSetData($eOutput, $currentRead, 1); make it dump this to the GUI edit box If StringInStr($currentRead, "Enter current volume label for drive") <> 0 Then; if any of those characters have the string "Enter current volume label for drive" then StdinWrite($ourProcess, DriveGetLabel($SystemDrives[$i]&"\") & @CRLF); write the appropriate drive label to the program EndIf EndIf EndIf $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelect WEnd Next GUICtrlSetData($eOutput,"Auto Convert is finished converting all non-ntfs drives!"& @CRLF, 1) Else MsgBox(0,"Error", "No other drives on the system need to be converted to NTFS!") EndIf ExitExcellent work and thankyou very much for your help!!!! everything seems to be working correctly no errors or bugs that i have found. I will be testing in different system over the next couple of days - will let you know how it all goes.
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