Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Password changer

$
0
0
Hi all...

I am trying to develope a script to allow my users to change their SQL login password from their own PC's (not members of a domain).

So far I have developed this simple cut down script but I have a problem I just can not resolve. The script has four input boxes, if any of them do not have acceptable values for the MSSQL connection string then the script fails, but I don't seem to be able to capture the @error... anyone got any idea?... please.


[ autoit ]         
$server = InputBox(@ScriptName, "Please enter target server.", "") If @error = 1 Then Exit $user = InputBox(@ScriptName, "Please enter your user name.", "") If @error = 1 Then Exit $old_password = InputBox(@ScriptName, "Please enter your old password.", "", "*M") If @error = 1 Then Exit $new_password = InputBox(@ScriptName, "Please enter your new password.", "", "*M") If @error = 1 Then Exit CONNECT() ; **** This line does not get reached if any of the input values are wrong??? **** If @error Then MsgBox (0, @ScriptName, "Connection failed, error code = " & @error & ". Outside function.") ;************************************************************* FUNCTION DECLARATION ******************************************************** Func CONNECT() $conn = ObjCreate("ADODB.Connection") $conn.ConnectionString = "DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=master;UID=" & $user & ";PWD=" & $old_password & ";" $conn.ConnectionTimeout = 30 $conn.Open ; **** This line does not get reached if any of the input values are wrong??? **** If @error Then MsgBox (0, @ScriptName, "Connection failed, error code = " & @error & ". Inside function.") $conn.CommandTimeout = 600 $conn.Execute("ALTER LOGIN [" & $user & "] WITH PASSWORD=N'" & $new_password & "' OLD_PASSWORD=N'" & $old_password & "'") $conn.Close EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>