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

Check user authentication to windows share

$
0
0
Hello everyone.

I'm trying to connect to a windows share (\\print) but if my authentication fails, for example, wrong username or password, how can i catch that error?
The problem is that when executing the script (exe. file), if i insert wrong credentials, the error message is from Autoit program and not the message i would like to pop up (code above) if there is some problem with the authentication.

Here is a sample of my code:
[ autoit ]      
;Here I try connect to the server \\print with username and password $WshNetwork = ObjCreate("WScript.Network") $WshNetwork.MapNetworkDrive("", "\\print", True, $username, $password)

The values of $username and $password are filled from an Inputbox.
So, after that code i tried to catch the error like this:

[ autoit ]      
if @error Then [indent=1]MsgBox(16, "", "Authentication error!")[/indent] EndIf

And by the way, the error i got from the console is this one:

C:\Users\user\Desktop\test.au3 (33) : ==> The requested action with this object has failed.:
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)
$WshNetwork.MapNetworkDrive( "","\\print",True, $username, $password)^ ERROR


Well, the error is happening, but is there some way to catch the error from the code and send an alert (Msgbox)?

Thank you for your help and time,
Sardinha

Viewing all articles
Browse latest Browse all 12506

Trending Articles



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