Skip to content

Commit dd7c353

Browse files
committed
Tweaked dxdiag timeout
1 parent 0e9b440 commit dd7c353

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

MTADiag/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
#include <time.h>
2727
#include "Log.h"
2828

29-
#define VERSION "2.7.18"
29+
#define VERSION "2.7.19"

MTADiag/Diag.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ void Diag::Begin ( void )
161161

162162
// gather the most useful system information first
163163
#ifndef SKIPDXDIAG
164-
DoSystemCommandWithOutput ( std::string( "dxdiag /t " ) + files[FILE_TEMP], OUTPUT_NONE );
164+
if ( DoSystemCommandWithOutput ( std::string( "dxdiag /dontskip /whql:off /t " ) + files[FILE_TEMP], OUTPUT_NONE, 120000 ) == WAIT_TIMEOUT )
165+
{
166+
// If timed out, try again but allow dxdiag to skip problem area
167+
ProgressBar ( 5 );
168+
DoSystemCommandWithOutput ( std::string( "dxdiag /whql:off /t " ) + files[FILE_TEMP], OUTPUT_NONE, 120000 );
169+
}
165170
ProgressBar ( 10 );
166171
#endif
167172
DoSystemCommandWithOutput ( "tasklist", OUTPUT_ANSI, 120000 );
@@ -589,7 +594,7 @@ void Diag::GetDir ( std::string directory )
589594
Log::WriteFileToLog ( files[FILE_TEMP].c_str(), ( directory + " directory listing" ) ); // write the result to the log file with a description
590595
}
591596

592-
void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWORD maxTimeMs )
597+
DWORD Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWORD maxTimeMs )
593598
{
594599
Log::WriteDividerToLog();
595600
time_t startTime = time( NULL );
@@ -631,6 +636,7 @@ void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWOR
631636

632637
ret = CreateProcess( NULL, (LPSTR)command.c_str(), NULL, NULL, TRUE, flags, NULL, NULL, &si, &pi );
633638

639+
DWORD status = ERROR_INVALID_FUNCTION;
634640
std::stringstream ss;
635641
if ( ret == 0 )
636642
{
@@ -640,7 +646,6 @@ void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWOR
640646
else
641647
{
642648
// Apply time limit for command to complete
643-
DWORD status = 1;
644649
for( unsigned int i = 0 ; i < maxTimeMs ; i += 100 )
645650
{
646651
status = WaitForSingleObject ( pi.hProcess, 100 );
@@ -652,6 +657,7 @@ void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWOR
652657
{
653658
TerminateProcess ( pi.hProcess, 1 );
654659
ss << command << " - ERROR: Unable to complete - timed out after " << maxTimeMs << " ms";
660+
Sleep( 1000 );
655661
}
656662
else
657663
if ( status != ERROR_SUCCESS )
@@ -681,4 +687,6 @@ void Diag::DoSystemCommandWithOutput ( std::string command, int outputType, DWOR
681687
Log::WriteFileToLog ( files[FILE_WMIC_UNI], ss.str() );
682688
remove ( files[FILE_WMIC_UNI].c_str() );
683689
}
690+
691+
return status;
684692
}

MTADiag/Diag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace Diag {
8585
void UpdateMTA ( void );
8686

8787
// information gathering functions
88-
void DoSystemCommandWithOutput ( std::string command, int outputType = OUTPUT_ANSI, DWORD maxTimeMs = 20000 );
88+
DWORD DoSystemCommandWithOutput ( std::string command, int outputType = OUTPUT_ANSI, DWORD maxTimeMs = 20000 );
8989
void GetDir ( std::string directory );
9090
void QueryWMIC ( std::string, std::string = "", std::string = "", std::string = "" );
9191

0 commit comments

Comments
 (0)