n0manarmy Posted October 9, 2012 Posted October 9, 2012 I am using autoit to run a series of commands to turn on the registry of a remote machine, delete profiles older than 14 days and then turn off the remote registry on our windows 7 machines. I cannot figure out how to either have the commands outputs displayed in their cmd boxes. I see no outputs when I turn on remote registry, delete old profiles, and then turn off the remote registry. The application works so far, however the outputs being displayed in some way or another would be great because it can take a long time to run. If I can use runwait or shellexecutewait to see the outputs of the commands I run it would be a huge help expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\Users\pwilbert\Desktop\temp\autodelprof.exe #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ;Profile cleanup automation utility ; #include <GUIConstantsEx.au3> ;declarations Global Const $mainWindow = GUICreate("Profile Deletion", 500, 500) Global Const $statusWindow = GUICtrlCreateList("", -1, 80, 500) Global Const $deleteProfiles = GUICtrlCreateButton("Del Profiles", 30, 50, 100) Global Const $computerNameInput = GUICtrlCreateInput("none", 150, 50, 100) Global Const $scCommand = "sc \\" Global Const $scStart = " start remoteregistry" Global Const $scQuery = " query remoteregistry" Global Const $scStop = " stop remoteregistry" Global $delprof = @TempDir & "\delprof2.exe /q /u /d:14 /c:\\" Global $computerName = String("none") Opt("GUIOnEventMode", 1) ; Change to OnEvent mode GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") GUICTRLSetOnEvent($deleteProfiles, "Main") GUISetState(@SW_SHOW) FileInstall("c:\users\pwilbert\Desktop\work\delprof\delprof2.exe", @TempDir & "\delprof2.exe", 1) While 1 Sleep(1000) WEnd ;starting of the application, makes respective calls. Func Main() $computerName = GUICtrlRead($computerNameInput) $startRemoteRegistry = $scCommand & $computerName & $scStart $stopRemoteRegistry = $scCommand & $computerName & $scStop $delprof = $delprof & $computerName GUICtrlSetData($statusWindow, "") Call ("StartRemoteRegistry", $startRemoteRegistry) Call ("DelProfiles", $delprof) Call ("StopRemoteRegistry", $stopRemoteRegistry) EndFunc Func StartRemoteRegistry($startRemoteRegistry) GUICtrlSetData($statusWindow, "Starting Remote Registry|") $results = RunWait($startRemoteRegistry) If $results = 0 Then GUICtrlSetData($statusWindow, "Success|") Else GUICtrlSetData($statusWindow, "Failed|") EndIf EndFunc Func StopRemoteRegistry($stopRemoteRegistry) GUICtrlSetData($statusWindow, "Stopping remote registry|") $results = RunWait($stopRemoteRegistry) If $results = 0 Then GUICtrlSetData($statusWindow, "Success|") Else GUICtrlSetData($statusWindow, "Failed|") EndIf EndFunc Func DelProfiles($delprof) GUICtrlSetData($statusWindow, "Deleting old profiles|") RunWait($delprof) WEnd EndFunc Func ExitApplication() Exit EndFunc
water Posted October 9, 2012 Posted October 9, 2012 (edited) You could replace RunWait with Run and use $STDOUT_CHILD to grab the output of the program. To wait until the program has finished use something like: Local $iPID = Run(...) Local $sStdOutRead = "" While ProcessExists($iPID) $sStdOutRead &= StdoutRead($iPID) WEnd Edited October 9, 2012 by water 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
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