Jump to content

RunWait output to file


Recommended Posts

I have spent the past couple of hours trying to find a solution to this. Is there a way to output the data from a RunWait to a text file? I need to use the RunWait as I need each command to complete before the next one starts. Any help would be greatly appreciated. I have tried

RunWait(@ComSpec & " /c " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&TAKEOWN /f " & GUICtrlRead($hFolder) & " /r /d y" > "C:\log.txt", "", @SW_HIDE)

But that does not work either. Here is my code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>



;=============Main=GUI=================
$hGUI = GUICreate("", 250, 500)
;======================================

;=================Inputs===============
$hOld = GUICtrlCreateInput("", 95, 25, 130)
$hNew = GUICtrlCreateInput("", 95, 50, 130)
$hOldSvr1 = GUICtrlCreateInput("", 95, 75, 25)
GUICtrlSetLimit(-1, 3)
$hOldSvr2 = GUICtrlCreateInput("", 130, 75, 25)
GUICtrlSetLimit(-1, 3)
$hOldSvr3 = GUICtrlCreateInput("", 165, 75, 25)
GUICtrlSetLimit(-1, 3)
$hOldSvr4 = GUICtrlCreateInput("", 200, 75, 25)
GUICtrlSetLimit(-1, 3)
$hNewSvr1 = GUICtrlCreateInput("", 95, 100, 25)
GUICtrlSetLimit(-1, 3)
$hNewSvr2 = GUICtrlCreateInput("", 130, 100, 25)
GUICtrlSetLimit(-1, 3)
$hNewSvr3 = GUICtrlCreateInput("", 165, 100, 25)
GUICtrlSetLimit(-1, 3)
$hNewSvr4 = GUICtrlCreateInput("", 200, 100, 25)
GUICtrlSetLimit(-1, 3)
$hLetter = GUICtrlCreateInput("", 95, 125, 130)
$hPath = GUICtrlCreateInput("", 95, 150, 130)
$hFolder = GUICtrlCreateInput("", 95, 175, 130)
$hUID = GUICtrlCreateInput("", 95, 200, 130)
$hExclude = GUICtrlCreateInput("", 95, 225, 130)
;======================================

;=================Buttons==============
$hButton1 = GUICtrlCreateButton("Test", 50, 260, 50)
;======================================

;=================Labels===============
$hLabel1 = GUICtrlCreateLabel("Old Domain", 10, 28)
$hLabel2 = GUICtrlCreateLabel("New Domain", 10, 53)
$hLabel3 = GUICtrlCreateLabel("Old Server (IP)", 10, 78)
$hLabel4 = GUICtrlCreateLabel("New Server (IP)", 10, 103)
$hLabel5 = GUICtrlCreateLabel("Drive Letter", 10, 128)
$hLabel5 = GUICtrlCreateLabel("Folder Path", 10, 153)
$hLabel6 = GUICtrlCreateLabel("Folder Name", 10, 178)
$hLabel7 = GUICtrlCreateLabel("User Name", 10, 203)
$hLabel8 = GUICtrlCreateLabel("Exclusions", 10, 228)
;======================================


GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMSG()
        Case $GUI_EVENT_CLOSE
            ExitLoop


        Case $hButton1
            _TestOnly()


    EndSwitch
WEnd
 
 
Func _TestOnly()
RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&TAKEOWN /f " & GUICtrlRead($hFolder) & " /r /d y")
RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&icacls " & GUICtrlRead($hFolder) & " /reset /T")
RunWait(@ComSpec & " /k " & GUICtrlRead($hLetter) & ":&&cd\" & GUICtrlRead($hPath) & "&&icacls " & GUICtrlRead($hFolder) & "\*.* /inheritance:d /c /t")
EndFunc

Thanks

Grimm

Link to comment
Share on other sites

  • Developers

Use Run() anyway and read the STDXXX until the program ends. The result is the same as Runwait but you are able to read the STDOUT and STDERR.

Check the helpfile for an example.

Jos

Edited by 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

×
×
  • Create New...