Exitcode er ikke som forventet
Hejsa.Jeg har lavet noget kode i Autoit. Den kode læser en SQL DB. Hvis det går godt, så er min exitcode 0 ellers er exitcode 99.
Hvis jeg kører min autoit kode i designtime, så kan jeg se at min exitcode er 99.
I mit VBScript kører jeg mit autoit exefil, men der er exitcode 0. Det forstår jeg ikke.
AutoIT kode:
; SetUP internal ADO.au3 UDF COMError Handler
_ADO_ComErrorHandler_UserFunction(_ADO_COMErrorHandler)
_Main()
Exit(0)
Func _Main()
Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';', $sQUERY, $oRecordset, $aRecordsetArray, $aRecordset_inner
Local $oConnection = _ADO_Connection_Create()
_ADO_Connection_OpenConString($oConnection, $sConnectionString)
If @error Then SetError(@error, @extended, $ADO_RET_FAILURE)
$sQUERY = "Select Shipdate from " & $sTableName & " where ComputerName = '" & @ComputerName & "'"
; $sQUERY = "Select Shipdate from " & $sTableName & " where ComputerName = 'DKSOLT1464'"
; ConsoleWrite($sQUERY & @TAB)
$oRecordset = _ADO_Execute($oConnection, $sQUERY)
If @error Then SetError(@error, @extended, $ADO_RET_FAILURE)
$aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False)
If @error Then SetError(@error, @extended, $ADO_RET_FAILURE)
$aRecordset_inner = _ADO_RecordsetArray_GetContent($aRecordsetArray)
If @error Then SetError(@error, @extended, $ADO_RET_FAILURE)
if Not IsArray($aRecordset_inner) Then Exit(99) ; <----- exit if computer does not exists in SQL DB
If $aRecordset_inner[0][0] = '' or $aRecordset_inner[0][0] = Null Then Exit(99)
RegWrite("HKEY_CURRENT_USER\SOFTWARE\ComputerInfo", "Shipdate", "REG_SZ", $aRecordset_inner[0][0])
EndFunc
VBScript kode:
Sub RegComputerInfo
Const HKEY_CURRENT_USER = &H80000001
Dim lstrKeyPath, lstrValueName, lstrValue, outFile, objFile, oExec
lstrKeyPath = "SOFTWARE\ComputerInfo\"
lstrValueName = "Shipdate"
if ADHelper.IsCurrentUserMember("DKSO_AllUsers") and (ADHelper.strComputerType <> "Server") then
objReg.GetStringValue HKEY_CURRENT_USER,lstrKeyPath,lstrValueName,lstrValue
if IsNull(lstrValue) then
' msgbox "EC"
set oExec = WSHShell.exec(strScriptPath & "\Support\Script\ComInventory\GetShipdate.exe")
msgbox oExec.Exitcode
msgbox "status " & oExec.status
msgbox "ProcessID " & oExec.ProcessID
if oExec.ExitCode = 99 then
outFile = "\\Server\path" & WSHNetwork.ComputerName & ".txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write strUsername & "|" & strModel & "|" & ServiceTag
objFile.Close
else
' msgbox "Test " & oExec.ExitCode
End if
End If
End if
End Sub 'FindShipDate
Håber nogen kan kaste et lys over det.