Sudiro Posted October 20, 2016 Share Posted October 20, 2016 (edited) Dear All.. Found this script in forum.. #include <Constants.au3> #RequireAdmin $hPrDiskPart = Run(@ComSpec & " /k " & "diskpart", @SystemDir,@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) StdinWrite($hPrDiskPart, "list disk" ) StdinWrite($hPrDiskPart) Local $data While True $data &= StdoutRead($hPrDiskPart & @CRLF) If @error Then ExitLoop Sleep(25) WEnd MsgBox(0, "", "List Disk: " & @CRLF & $data) ; I want This MsgBox Only Show Disk### (Disk0, Disk1,...) How to make msgbox only show disk number..? Not show all text in dispart /list Edited October 20, 2016 by Sudiro Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 20, 2016 Share Posted October 20, 2016 May be this help you #include <Constants.au3> #include <Array.au3> #RequireAdmin $hPrDiskPart = Run(@ComSpec & " /k " & "diskpart", @SystemDir,@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) StdinWrite($hPrDiskPart, "list disk" ) StdinWrite($hPrDiskPart) Local $data While True $data &= StdoutRead($hPrDiskPart & @CRLF) If @error Then ExitLoop Sleep(25) WEnd $array = StringRegExp($data,"\w[disk]+\s+\d",1) _ArrayDisplay($array) Link to comment Share on other sites More sharing options...
Sudiro Posted October 20, 2016 Author Share Posted October 20, 2016 7 hours ago, Muhammad_Awais_Sharif said: May be this help you #include <Constants.au3> #include <Array.au3> #RequireAdmin $hPrDiskPart = Run(@ComSpec & " /k " & "diskpart", @SystemDir,@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) StdinWrite($hPrDiskPart, "list disk" ) StdinWrite($hPrDiskPart) Local $data While True $data &= StdoutRead($hPrDiskPart & @CRLF) If @error Then ExitLoop Sleep(25) WEnd $array = StringRegExp($data,"\w[disk]+\s+\d",1) _ArrayDisplay($array) Only Show Disk0, If Insert USB/flashdisk, Disk1, Disk2 Not show in array.. Link to comment Share on other sites More sharing options...
Muhammad_Awais_Sharif Posted October 21, 2016 Share Posted October 21, 2016 change in this line $array = StringRegExp($data,"\w[disk]+\s+\d",1) to this $array = StringRegExp($data,"\w[disk]+\s+\d",3) Full Code Working for me #include <Constants.au3> #include <Array.au3> #RequireAdmin $hPrDiskPart = Run(@ComSpec & " /k " & "diskpart", @SystemDir,@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) StdinWrite($hPrDiskPart, "list disk" ) StdinWrite($hPrDiskPart) Local $data While True $data &= StdoutRead($hPrDiskPart & @CRLF) If @error Then ExitLoop Sleep(25) WEnd $array = StringRegExp($data,"\w[disk]+\s+\d",3) _ArrayDisplay($array) Link to comment Share on other sites More sharing options...
Sudiro Posted October 22, 2016 Author Share Posted October 22, 2016 On 21/10/2016 at 8:15 AM, Muhammad_Awais_Sharif said: change in this line $array = StringRegExp($data,"\w[disk]+\s+\d",1) to this $array = StringRegExp($data,"\w[disk]+\s+\d",3) Full Code Working for me #include <Constants.au3> #include <Array.au3> #RequireAdmin $hPrDiskPart = Run(@ComSpec & " /k " & "diskpart", @SystemDir,@SW_HIDE,$STDIN_CHILD + $STDOUT_CHILD) StdinWrite($hPrDiskPart, "list disk" ) StdinWrite($hPrDiskPart) Local $data While True $data &= StdoutRead($hPrDiskPart & @CRLF) If @error Then ExitLoop Sleep(25) WEnd $array = StringRegExp($data,"\w[disk]+\s+\d",3) _ArrayDisplay($array) Thank's Sharif.. Muhammad_Awais_Sharif 1 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