colombeen

Get description for hex error code

10 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

#6 ·  Posted

How do you call certutil in your AutoIt script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

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

#8 ·  Posted (edited)

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

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