Hallo
ich habe folgenden Scriptcode, der mir eine Anmeldung an die AS400 sendet. Falls ich Falscheingaben mache bekomme ich auch dementsprechende Rückgabewerte.
Ich möchte nun bei Falscheingabe des user oder Passwortes, das mir das Fenster zur Usereingabe und Passworteingabe nochmal gezeigt wird und ich die Eingaben erneut tätigen kann.
Bei meinem Code kommt zwar das fenster aber er macht im Prinzip einfach ein 2 tes Formualr auf. Liegt an der Funktion Error() wahrscheinlich.
Kann mir jemand helfen das zu lösen ?
Wäre super.
Spoiler anzeigen
#include <string.au3>
#include <GUIConstants.au3>
Dim $useridibm
Dim $userid
Dim $useridsignonmode
Dim $useridsoftm
Dim $password
Dim $userpassver
Dim $userpassent
Dim $userpassreg
Dim $NameAS400
Dim $okbutton
Dim $objConnection
Dim $objError
Dim $nMsg
Dim $err
Dim $temp
Run("regedit /s D:\Start\Reg\Alkor_Suite_T0.reg")
[/autoit] [autoit][/autoit] [autoit]$NameAS400 = RegRead("HKEY_CURRENT_USER\Software\SoftM\Global\Parametersteuerung", "System")
$useridibm = RegRead("HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication", "User ID")
$useridsignonmode = RegRead("HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication", "Signon Mode")
$useridsoftm = RegRead("HKEY_CURRENT_USER\Software\SoftM\Global\Environment", "StandardUser")
$userpassreg = RegRead ( "HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication" ,"User PW")
RegWrite ( "HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication" ,"Signon Mode", "REG_DWORD", 1)
$objConnection = ObjCreate("ADODB.Connection")
$objError = ObjEvent("AutoIt.Error","Error")
uidpwd()
[/autoit] [autoit][/autoit] [autoit]Run("D:\Program Files\SoftM AG\SoftM AG Suite\smumenu.exe")
[/autoit] [autoit][/autoit] [autoit]Func uidpwd()
If ($useridsoftm = "" and $useridibm = "") or ($useridsoftm = "" and $useridibm <> "") Then
GUICreate("Anmeldung AS/400", 200, 200)
GUICtrlCreateLabel("AS/400 UserName:", 42, 35, 131, 27)
$userid = GUICtrlCreateInput("", 42, 50, 121, 21)
GUICtrlCreateLabel("AS/400 Passwort:", 42, 85, 111, 17)
$password = GUICtrlCreateInput("", 42, 100, 121, 21)
$okbutton = GUICtrlCreateButton("OK", 70, 145, 60)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $okbutton
$userid = GUICtrlRead($userid)
$password = GUICtrlRead($password)
Logon()
;msgbox(4096,"Rückgabe Logon","Rückgabe Logon: " & $temp)
OKUserPasswort($NameAS400, $userid, $password)
ExeCWBLogon()
GUISetState(@SW_HIDE)
ExitLoop
EndSwitch
WEnd
Else
if ($userpassreg <> "" And $useridibm<>"") or ($useridsoftm <> "") Then
if $useridsoftm <> "" Then
RegWrite ( "HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication" ,"User ID", "REG_SZ", $useridsoftm)
EndIf
$userpassent = _StringEncrypt ( 0, $userpassreg, "19passwort19encrypten74" , 2)
$password = $userpassent
;msgbox(4096,"Titel","Password: " & $password)
$userid = $useridsoftm
;msgbox(4096,"Titel","Userid: " & $userid)
Logon()
ExeCWBLogon()
EndIf
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func Logon()
[/autoit] [autoit][/autoit] [autoit]$objConnection.Provider = "IBMDA400"
$objConnection.Properties("Data Source") = $NameAS400
$objConnection.Properties("User ID") = $userid
$objConnection.Properties("Password") = $password
$objConnection.open
EndFunc
Func Error()
[/autoit] [autoit][/autoit] [autoit]Msgbox(0,"Fehler bei Anmeldung iSeries","" & @CRLF & _
"" & $objError.description & @CRLF )
if $objError.description <> "" Then
uidpwd()
EndIf
Local $err = $objError.number
If $err = 0 Then $err = -1
SetError($err) ; to check for after this function returns
Endfunc
Func OKUserPasswort($NameAS400, $userid, $password)
ShellExecute("C:\Program Files\IBM\Client Access\cwblogon.exe", " " & $NameAS400 & " /u " & $userid & " /p " & $password,@SW_HIDE)
RegWrite ( "HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication" ,"User ID", "REG_SZ", $userid)
$userpassver = _StringEncrypt(1, $password, "19passwort19encrypten74", 2)
RegWrite ( "HKEY_CURRENT_USER\Software\IBM\Client Access Express\CurrentVersion\Environments\My Connections\"& $NameAS400 &"\Communication" ,"User PW", "REG_SZ", $userpassver)
EndFunc
Func ExeCWBLogon()
ShellExecute("C:\Program Files\IBM\Client Access\cwblogon", " " & " /c")
ShellExecute("C:\Program Files\IBM\Client Access\cwblogon", " " & $NameAS400 & " /u " & $userid & " /p " & $password)
msgbox(4096,"Titel","Userid + PW + AS400: " & $userid & $password & $NameAS400)
EndFunc