Jump to content
colombeen

Get description for hex error code

Recommended Posts

colombeen

Hi everyone

 

I've been looking around but I can't seem to find any posts on this...

Is there an easy way to get the error description for a hex error code?

When I run certutil from within autoit it returns an error code but nothing else if there is a problem

I'd like to convert the code to the actual description.

 

Thx for the help

Colombeen

Share this post


Link to post
Share on other sites
water

Can you please post an example of the error code you are talking about?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

When i run the following cmd I get the error code plus description:

Quote

C:\Users\xx>certutil asdf
CertUtil: -dump-Befehl ist fehlgeschlagen: 0x80070002 (WIN32: 2)
CertUtil: Das System kann die angegebene Datei nicht finden.

So you could simply extract the error message from the data returned by certutil.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

Another possible way is to extract the windows error code and run net helpmsg.

Quote

net helpmsg 2

which returns the same error message.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
colombeen

certutil only returns this to autoit : -2147024810 (Hex: 80070056)

in this case: a bad password for the pfx file

Edited by colombeen

Share this post


Link to post
Share on other sites
water

How do you call certutil in your AutoIt script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
colombeen
Just now, water said:

How do you call certutil in your AutoIt script?

Local $DGCERTINST_COMMAND = 'certutil -f -user -p "' & $DGCERTINST_PASSWORD & '_" -importpfx "' & $DGCERTINST_CERT_PATH & '"'
Local $DGCERTINST_TRY_INSTALL = RunWait($DGCERTINST_COMMAND, "", @SW_HIDE)

$DGCERTINST_TRY_INSTALL contains the return code

Share this post


Link to post
Share on other sites
water

You could grab the output of certutil and extract the error message.

#include <AutoItConstants.au3>
Local $iPID = Run("Certutil afds", "", Default, $STDOUT_CHILD)
; Wait until the process has closed using the PID returned by Run
ProcessWaitClose($iPID)
; Read the Stdout stream of the PID returned by Run
Local $sOutput = StdoutRead($iPID)
ConsoleWrite("StdOut: " & $sOutput & @CRLF)

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

A bit more elaborated:

#include <AutoItConstants.au3>
#include <StringConstants.au3>

Local $iPID = Run("Certutil afds", "", Default, $STDOUT_CHILD)
; Wait until the process has closed using the PID returned by Run
ProcessWaitClose($iPID)
; Read the Stdout stream of the PID returned by Run
Local $sOutput = StdoutRead($iPID)
Local $aMessage = StringSplit($sOutput, @CRLF, $STR_ENTIRESPLIT)
If IsArray($aMessage) And $aMessage[0] > 1 And StringInStr($aMessage[1], "(Win32: ") Then
    ConsoleWrite("Error returned by certutil:" & @CRLF & $aMessage[2] & @CRLF)
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
colombeen
1 hour ago, water said:

A bit more elaborated:

#include <AutoItConstants.au3>
#include <StringConstants.au3>

Local $iPID = Run("Certutil afds", "", Default, $STDOUT_CHILD)
; Wait until the process has closed using the PID returned by Run
ProcessWaitClose($iPID)
; Read the Stdout stream of the PID returned by Run
Local $sOutput = StdoutRead($iPID)
Local $aMessage = StringSplit($sOutput, @CRLF, $STR_ENTIRESPLIT)
If IsArray($aMessage) And $aMessage[0] > 1 And StringInStr($aMessage[1], "(Win32: ") Then
    ConsoleWrite("Error returned by certutil:" & @CRLF & $aMessage[2] & @CRLF)
EndIf

 

thx water, i'll try this in a few mins

Share this post


Link to post
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

×