
RedemptionBlue
Members-
Posts
14 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by RedemptionBlue
-
Ok, So the script that I set out to make has been created successfully. My only problem at the moment is some debugging issues. I find that often my new script has an error that is quite odd. Here is my finished product: Local $user = InputBox("B:", "Enter your username", "", "", 215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf If $user <> "tony" and $user <> "clare" and $user <> "ric" Then Msgbox(0, "Failure", "The username is not recognised") Exit EndIf Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf DriveMapDel("B:") DriveMapAdd("B:", '\\NAS-EA-B6-EF\Beaches', 0, "domain\" & $user, $passwd) If @error = 1 Then MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended & @CRLF & "Please contact your IT Support") Exit ElseIf @error = 2 Then MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied") Exit ElseIf @error = 3 Then MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned") Exit ElseIf @error = 4 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name") Exit ElseIf @error = 5 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share") Exit ElseIf @error = 6 Then MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password" & @CRLF & "If you have forgotten your password please contact IT Support") Exit EndIf MsgBox(1, "B:", "You have been logged into B:") #cs ShellExecute("C:\Network Authentication\login.bat", $passwd) <-- OLD CODE FOR BATCH EXECUTION - ONLY USE IF DriveMapAdd DOESN'T WORK #ce I find that often my error message for @error = 1 is showing up. The @extended value is one that corresponds to a windows error. I do not know why sometimes the error is thrown and other times it isn't. That WinAPI error that I get returned is for an error regarding multiple logins to the share using the same or different credentials. It should not matter. I have the NAS (Which is what I am logging into at \\NAS-EA-B6-EF ) Fully set up with three accounts named ric, clare and tony. Each account has access to Beaches which is usually a read/write protected share. I connect in the only way that windows can and sometimes it wont let me log in, other times it will. If I get the multiple connections error, then I have to navigate through my network in explorer, into the NAS and then into Beaches. Windows prompts for user/pass automatically and I can get in fine. It is just mapping the drives that is a problem. Anyone that can shed some light here would be a life saver cheers
-
If I get rid of the #cs/ce tags on the username authentication code then I get an error on running the script. I will get back to a machine with the script and autoit on it and I will get back to you with the error.
-
Thank you for all the help so far, my "end-product" is getting closer to completion so to speak. Just trying to make it so that if the username supplied is not one of the 3 that are allowed to gain access then it says something like "Unknown Username" Or what not. My entire script is: Local $user = InputBox("B:", "Enter your username", "", "", 215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf #cs If $user <> tony and $user <>clare and $user <> ric Then Msgbox(0, "Failure", "The username is not recognised") Exit EndIf #ce Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf DriveMapDel("B:") DriveMapAdd("B:", '\\10.0.0.20\Beaches', 0, "domain\" & $user, $passwd) If @error = 1 Then MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended & @CRLF & "Please contact your IT Support") Exit ElseIf @error = 2 Then MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied") Exit ElseIf @error = 3 Then MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned") Exit ElseIf @error = 4 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name") Exit ElseIf @error = 5 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share") Exit ElseIf @error = 6 Then MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password" & @CRLF & "If you have forgotten your password please contact IT Support") Exit EndIf MsgBox(1, "B:", "You have been logged into B:") As you can see I have placed my attempt at the username authentication in #cs/ce tags. If I cannot do it in the simpler format that I have attempted I will just make it so that it is an if statement where if $user = tony Then execute script, else if $user = clare Then execute script, else if $user = ric execute script, else Exit. I would rather not do that as I am a Java programmer and it seems to me like just sloppy code but I just do not quite have the syntax/semantics of if statements in autoit fully understood. Cheers
-
The credentials are 100% correct. There seems to be problems with windows and authentication of these drives sometimes. The error regarding bad creds is inconsistent and often the script will just work. I find after a restart, sometimes it is fixed. Also, there are only 3 users that have access to the drive and for the sake of well... because I can, I want to make it so if the username of either clare, ric or tony is not entered then the script gives you a MsgBox() and Exits. Here is my code for it that I tried, but I have looked around on the forums, tutorials and google only to not find anyone else explaining how to do this. Local $user = InputBox("B:", "Enter your username", "", "", 215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf If $user <> tony and $user <>clare and $user <> ric Then Msgbox(0, "Failure", "The username is not recognised") Exit EndIf Thanks for that
-
My script works sometimes but not all the time. Sometimes it logs me in no worries, other times it returns @error = 1 so I get the unknown error message with a value of @extended = 1219. Any ideas? I think it is a windows networking issue because when I try to do the DOS command for adding a drive I get an error regarding mapped drives and multiple users, although often I am only logging in from the singular machine. Windows' networking needs a rethink, I also get errors where it refuses to delete a mapped drive but also won't reconnect either. (Sorry i will stop ranting about windows as this is not the place). My Code as of now: Local $user = InputBox("B:", "Enter your username", "", "", 215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf DriveMapDel("B:") DriveMapAdd("B:", '10.0.0.20Beaches', 0, "domain" & $user, $passwd) If @error = 1 Then MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended) Exit ElseIf @error = 2 Then MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied") Exit ElseIf @error = 3 Then MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned") Exit ElseIf @error = 4 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name") Exit ElseIf @error = 5 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share") Exit ElseIf @error = 6 Then MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password") Exit EndIf MsgBox(1, "B:", "You have been logged into B:") The batch code that I use and sometimes get the error(Could be related): net use B: /delete net use B: 10.0.0.20Beaches /user:domainusername FYI, username etc are spoofed. Cheers
-
@extended has a value of 0. Does that mean that it was not assigned or does the function have a reason behind a 0 value? Either way, will it help me fix the issue? Cheers
-
What can I do to check the value or @extended, just MsgBox(0, "Extended Check", "The value of @extended is " & @extended) ? Cheers EDIT: Used the code I just mentioned and @extended printed as 0.
-
Having Trouble with DriveMapAdd. It keep returning @error = 1 Here is my Code at the moment. Local $user = InputBox("B:", "Enter your username", "", "", 215,137) Local $passwd = InputBox("Attempting to Access B:", "Please enter your password", "", "*",215,137) If @error = 1 Then Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2) Sleep(2000) Exit ElseIf @error = 2 Then Msgbox(0,"", "The InputBox timed out!") EndIf DriveMapDel("B:") DriveMapAdd("B:", '\\10.0.0.20\Beaches', 8, "domain\" & $user, $passwd) If @error = 1 Then MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error") Exit ElseIf @error = 2 Then MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied") Exit ElseIf @error = 3 Then MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned") Exit ElseIf @error = 4 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name") Exit ElseIf @error = 5 Then MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share") Exit ElseIf @error = 6 Then MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password") Exit EndIf MsgBox(1, "B:", "You have been logged into B:") Every single time, I get the MsgBox that I set for @error = 1. Any Ideas why, is my code wrong(quite likely)?
-
Thank you Spiff. I managed to make it work using the command-line parameter method. I would still like to eliminate the need for the .bat but I have played with executing the net use straight out of AutoIt and can't seem to get it. I will use my knowledge gained today to work on my logout script now. Thank you again. Is there a way that I can give you "rep" or something? You have been very helpful. Cheers
-
Learning To Script with AutoIt V3
RedemptionBlue replied to BrettF's topic in AutoIt General Help and Support
I noticed that alot of the tutorials, guides and the likes around AutoIt seem to be over a year old. What is the support and learning resource base like these days. I am very interested in getting into using AutoIt, however the Docs are very unclear and the tutorials often do not cover information that many must assume you know(but I don't). For example people just say "Check your @error value to decided what to do next", I don't know how to check, use or implement Macros at all and just some highly basic, up-to-date info would be brilliant. Cheers. -
Hi Spiff, Thank you for your swift reply. I would love to get rid of the batch alltogether, it would be much cleaner indeed. I have not found too many tutorials as to how to use the AutoIt API and I keep seeing references to the @error value, yet I do not know how to check it's value, utilise it's value or even know anything about it other than the fact that it is returned by many functions. I also do not quite get what you mean by sending the password as a command line parameter. The Batch file does the share authentication process perfectly, the reason I wanted to use AutoIt is because I work in an office and the Black and white CMD interface is scary for some of the end users. A 'nicer' GUI would be ideal. Thank you for any help, it is all appreciated, learning is always great!
-
Also, Does anyone know of a way to make it so that if someone clicks the cancel button, the rest of the script terminates? Cheers
-
Hey guys, I am very new to using AutoIt and wrote my first little script today after reading bits and pieces on the docs. The script is designed to make an ugly batch operation a bit more user friendly for the people in the office. I have a batch file that consists of: @echo off net use B: /delete net use B: \\10.10.10.10\Share /user:domain\username It is used to log a user onto a secure share drive on my NAS. I have spoofed the share location etc. however. My AutoIt Script is: Local $passwd = InputBox("Attempting to Access B:", "Enter your password.", "", "*","M") Run("C:\Users\User\Desktop\login.bat") WinWaitActive("C:\Windows\system32\cmd.exe") Send($passwd) Now this works fine, however once I input my password into the GUI and it Sends that Password to the cmd window, I cannot make it send an "ENTER" Keystroke. It isn't a HUGE issue as I can manually press enter once the cmd window shows up, but I would like it to input the password and do the carriage return straight away. I have tried using Send("{ENTER}") , and it returns an error. I have tried changing the way I implement the sending of {ENTER} in as many ways as I can think of. I would greatly appreciate it if anyone can help me on this. Also, if anyone knows of a way to run the cmd window silently but still be able to send the password to it that would be even better! Cheers