Jump to content

pipe @comespec how to do ?


faustf
 Share

Recommended Posts

hi guys  i tryed  to pass a command at cmd   i create this  script   but not  work  someone can help me ?  thankz

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.5
 Author:         faustf

 Script Function:
     Remove recovery partition

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>

#RequireAdmin

Opt("GuiOnEventMode", 1)
Opt("GUICloseOnESC", 0)

_Gui()


Func _Gui()

    $Form1 = GUICreate("Recovery Remover", 429, 253, 875, 297)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenu("Help")
$MenuItem4 = GUICtrlCreateMenuItem("F1", $MenuItem3)
$Group1 = GUICtrlCreateGroup("Disk in da House", 3, 8, 422, 217)
$ListDisk = _ListView_OK("", 6, 32, 415, 136, "Disk_50_Status_70_Size_50_Free_60_Dyn_50_Gpt_50")
$Button1 = GUICtrlCreateButton("Erase Recover Partition", 288, 192, 131, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

_Load_Disk()

GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")

;GUICtrlSetOnEvent($Button1, "_ok")

EndFunc



Func _Load_Disk()

    ;Local $iPID = Run(@ComSpec & 'list disk ', $sFilePath, @SW_HIDE, $STDOUT_CHILD)
    ;Local $iPID = Run(@ComSpec & ' diskpart'  , @ScriptDir, @SW_MAXIMIZE ,  $STDOUT_CHILD)
    Local $iPID = Run(@ComSpec & " /c " &'diskpart', "", @SW_HIDE,  $STDOUT_CHILD)

    ; If you want to search with files that contains unicode characters, then use the /U commandline parameter.

    ; Wait until the process has closed using the PID returned by Run.
    ;ProcessWaitClose($iPID)
Sleep(5000)
StdinWrite($iPID, "list disk" & @CRLF)
Sleep(3000)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StdoutRead($iPID)
    MsgBox(0,'',$sOutput)
    ConsoleWrite($sOutput)

EndFunc

Func _ListView_OK($text, $left, $top, $width, $height, $Column, $SingleSEL = "")
    If $SingleSEL = "" Then
        Global $vGName = GUICtrlCreateListView($text, $left, $top, $width, $height, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    Else
        Global $vGName = GUICtrlCreateListView($text, $left, $top, $width, $height, BitOR($LVS_EDITLABELS, $LVS_REPORT, $LVS_SINGLESEL))
    EndIf
    _GUICtrlListView_SetExtendedListViewStyle($vGName, BitOR($LVS_EX_INFOTIP, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_HEADERDRAGDROP)) ; questa stringa fa la griglia stile excel
    Global $hLV = GUICtrlGetHandle($vGName)

    Local $aColumn = StringSplit($Column, "_")

    For $i = 1 To UBound($aColumn) - 1
        _GUICtrlListView_AddColumn($vGName, $aColumn[$i], $aColumn[($i + 1)]) ; Utente fake
        $i += 1
    Next
;   _True_write_File("C:\_GESTIONALE_NEW\TEMP\handle_listview.txt", $vGName)

    Return $vGName

EndFunc   ;==>_ListView_OK

While 1

Sleep(100)
    WEnd

Func _close()
    Exit
EndFunc   ;==>_close

 

Link to comment
Share on other sites

You still have to wait for the process to close before reading the output with StdOutRead.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

but  how  ?  i try to do in this mode  but not  work

Func _Load_Disk()

    ;Local $iPID = Run(@ComSpec & 'list disk ', $sFilePath, @SW_HIDE, $STDOUT_CHILD)
    ;Local $iPID = Run(@ComSpec & ' diskpart'  , @ScriptDir, @SW_MAXIMIZE ,  $STDOUT_CHILD)
    Local $iPID = Run(@ComSpec & " /c " &'diskpart', "", @SW_HIDE,  $STDOUT_CHILD)

    ; If you want to search with files that contains unicode characters, then use the /U commandline parameter.

    ; Wait until the process has closed using the PID returned by Run.
    ;ProcessWaitClose($iPID)
Sleep(10000)
StdinWrite($iPID, "list disk" & @CRLF)
ProcessWaitClose($iPID)
Sleep(3000)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StdoutRead($iPID)
    MsgBox(0,'',$sOutput)
    ConsoleWrite($sOutput)

EndFunc

 

Link to comment
Share on other sites

  • Developers

The answer was already given. ;) Try this example and modify it to your needs:

#include <AutoItConstants.au3>
_Load_Disk()

Func _Load_Disk()
    Local $iPID = Run(@ComSpec & ' /k dir ', "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
    Sleep(1000)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StdoutRead($iPID) = ' & StdoutRead($iPID) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    ;
    StdinWrite($iPID, "dir *.au3" & @CRLF)
    StdinWrite($iPID, "Exit" & @CRLF)
    ProcessWaitClose($iPID)
    Sleep(1000)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StdoutRead($iPID)
    ConsoleWrite($sOutput)

EndFunc   ;==>_Load_Disk

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...