Share via


Windows Troubleshooter: How to add custom diagnostic scripts

Introduction

Many times when we face a problem in Windows, our first attempt to troubleshoot the problem is to run the built-in troubleshooter.

A lot of scenarios exist wherein we run the diagnostics tool\troubleshooter, like to diagnose network connectivity issues, audio issues, etc.

The troubleshooter can be accessed from Control Panel->System and Security->Troubleshoot common problems.

Requirements

The operations involved are governed by a set of PowerShell scripts (.ps1) controlled by Microsoft Automated Support Diagnostics Platform. The platform requires Diagnostic Policy Service and Diagnostic Service Host service running. At the time an issue occurs, a list of scripts pertaining to that particular area are executed one-by-one and the results after each execution are verified to make sure the issue is solved. If the issue is not solved with the execution of one script, the next script is executed. When all the scripts are executed, but the issue persists, the message “Troubleshooting was unable to automatically fix all of the issues found” is displayed.

Scripts

The scripts are located in the directory %windir%\diagnostics, with each set of scripts present in separate folders bearing the name of the area for which the scripts are made for. The scripts are linked by ‘Troubleshooting Pack’ file (DiagPackage.diagpkg) inside each folder. The necessary functions/definitions are defined in DiagPackage.dll whose size varies with the area. The logic of proceeding to the next script, getting output from each step and verifying, etc. are defined in the DLL file. The scripts can be edited or new scripts can be added. The DiagPackage.diagpkg file can be edited using Notepad to add/edit the scripts that have to be executed.

Based on the nature of work, the scripts used here are classified into three types:  

  1. troubleshooter, 
  2. resolver and
  3. verifier.

Troubleshooter

Troubleshooter (referred as TS) detects a problem and finds a fix.

Resolver

Resolver (referred as RS) applies the fix.

Verifier

 Verifier (referred as VF) verifies the resolution.

New category

Creation of a new category of troubleshooter requires that an XML file be defined with the DLL in the index folder and defining a new DLL file as well. A new folder by the name of the new category must be created in the system folder and the corresponding PowerShell scripts have to present inside this folder. The linking of files must also be done inside the same folder.

See Also