gahhon Posted January 31, 2019 Posted January 31, 2019 RunWait(@ComSpec & ' /c attrib +s +h "' & $DIR_WA_FOLDER & '"', @UserProfileDir, @SW_HIDE) RunWait(@ComSpec & ' /c icacls "' & $DIR_WA_FOLDER & '" /DENY EVERYONE:F ', @UserProfileDir, @SW_HIDE) How can I capture error message from RunWait if failure on executing, and print the error message to .log file. _FileWriteLog($LOG_SECURITY, "Error: <Error Message Here>")
Moderators JLogan3o13 Posted January 31, 2019 Moderators Posted January 31, 2019 Runwait is not going to error as long as it successfully launches @ComSpec. What you're looking for is any error messages from within the command window. Here is an example of reading from the command line: #include <Constants.au3> $net = Run(@ComSpec & " /c defrag.exe C:\ /A", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($net) If @error Then ExitLoop If $line <> "" Then MsgBox(0, "STDOUT read:", $line) Wend "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
gahhon Posted January 31, 2019 Author Posted January 31, 2019 1 minute ago, JLogan3o13 said: Runwait is not going to error as long as it successfully launches @ComSpec. What you're looking for is any error messages from within the command window. Here is an example of reading from the command line: #include <Constants.au3> $net = Run(@ComSpec & " /c defrag.exe C:\ /A", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($net) If @error Then ExitLoop If $line <> "" Then MsgBox(0, "STDOUT read:", $line) Wend Oh I see. Because I just want make a proper application that can capture everything tho. Since you're saying that @Comspec is not going to error as long as it launches successfully. But anyway, thanks for your sample tho.
Moderators JLogan3o13 Posted January 31, 2019 Moderators Posted January 31, 2019 Runwait is running the command line, so as long as that executes, the RunWait command will not error out. If you want any errors generated by what you're doing inside the command line window, you have the read the STDOUT. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
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