IvanCodin Posted February 23, 2008 Share Posted February 23, 2008 (edited) When I run this function _rundos in a script the dos window stays minimized. I assume this works as designed correct? I don't seem to be getting the error from the rasdial command. I have confirmed at command prompt they are being sent. Here is a snippet of the script: CODEFunc _DialRAS () If GUICtrlRead($Input_1) = "" Then MsgBox(0,"Notice - Error", "Please select a RAS port and Retry",0) ; GUISetState (@SW_HIDE) ; MsgBox(0, "Info", "You connection will use " & GUICtrlRead($Input_1) & " and call " & GUICtrlRead($Input_3), 3) _RunDOS ("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) ; Run ("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) If @error = 720 Then MsgBox(16, "RAS Error", "Login script error", 3) If @error = 680 Then MsgBox(16, "RAS Error", "No dialtone", 3) If @error = 678 Then MsgBox(16, "RAS Error", "There was no answer", 3) If @error = 677 Then MsgBox(16, "RAS Error", "A person answered instead of a modem", 3) If @error = 676 Then MsgBox(16, "RAS Error", "Line is busy", 3) If @error <> 0 Then MsgBox(16, "RAS Error", "An unknown error has occured", 3) ; If @error = 0 Then MsgBox(32, "RAS Info", "The RAS connection was successful", 3) EndFunc Thanks CC Edited February 23, 2008 by IvanCodin Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 24, 2008 Share Posted February 24, 2008 When I run this function _rundos in a script the dos window stays minimized. I assume this works as designed correct? I don't seem to be getting the error from the rasdial command. I have confirmed at command prompt they are being sent. Here is a snippet of the script: CODEFunc _DialRAS () If GUICtrlRead($Input_1) = "" Then MsgBox(0,"Notice - Error", "Please select a RAS port and Retry",0) ; GUISetState (@SW_HIDE) ; MsgBox(0, "Info", "You connection will use " & GUICtrlRead($Input_1) & " and call " & GUICtrlRead($Input_3), 3) _RunDOS ("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) ; Run ("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) If @error = 720 Then MsgBox(16, "RAS Error", "Login script error", 3) If @error = 680 Then MsgBox(16, "RAS Error", "No dialtone", 3) If @error = 678 Then MsgBox(16, "RAS Error", "There was no answer", 3) If @error = 677 Then MsgBox(16, "RAS Error", "A person answered instead of a modem", 3) If @error = 676 Then MsgBox(16, "RAS Error", "Line is busy", 3) If @error <> 0 Then MsgBox(16, "RAS Error", "An unknown error has occured", 3) ; If @error = 0 Then MsgBox(32, "RAS Info", "The RAS connection was successful", 3) EndFunc Thanks CC You didn't save the return code to use. The @error macro reports error codes from AutoIt functions, as set by the SetError() command. It is NOT the same thing as %ERRORLEVEL% from the shell. Try it more like this: Func _DialRAS() If GUICtrlRead($Input_1) = "" Then MsgBox(0, "Notice - Error", "Please select a RAS port and Retry", 0) $RET = _RunDOS("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) Switch $RET Case 0 MsgBox(32, "RAS Info", "The RAS connection was successful", 3) Case 720 MsgBox(16, "RAS Error", "Login script error", 3) Case 680 MsgBox(16, "RAS Error", "No dialtone", 3) Case 678 MsgBox(16, "RAS Error", "There was no answer", 3) Case 677 MsgBox(16, "RAS Error", "A person answered instead of a modem", 3) Case 676 MsgBox(16, "RAS Error", "Line is busy", 3) Case Else MsgBox(16, "RAS Error", "An unknown error has occured", 3) EndSwitch EndFunc ;==>_DialRAS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
IvanCodin Posted February 24, 2008 Author Share Posted February 24, 2008 Thank You! Thank You! This did the trick. I did have to change your suggestions just a bit though. I moved the 0 return code to the bottom of the case statement and my errors were returned successfully!!!! Reminds how painful dos batch scripts were! CODEFunc _DialRAS() If GUICtrlRead($Input_1) = "" Then MsgBox(0, "Notice - Error", "Please select a RAS port and Retry", 0) $RET = _RunDOS("rasdial " & GUICtrlRead($Input_1) & " /phone:" & GUICtrlRead($Input_3)) Switch $RET Case 720 MsgBox(16, "RAS Error", "Login script error", 3) Case 680 MsgBox(16, "RAS Error", "No dialtone", 3) Case 678 MsgBox(16, "RAS Error", "There was no answer", 3) Case 677 MsgBox(16, "RAS Error", "A person answered instead of a modem", 3) Case 676 MsgBox(16, "RAS Error", "Line is busy", 3) Case 0 MsgBox(32, "RAS Info", "The RAS connection was successful", 3) Case Else MsgBox(16, "RAS Error", "An unknown error has occured", 3) EndSwitch EndFunc ;==>_DialRAS Thanks Again CC Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now