Jac Posted September 25, 2008 Share Posted September 25, 2008 I have a script that run when user logon and sometime i get this error Line -1: Error: The requested action with this object has failed How can i debug that kind of error ? Is it possible that user don't see that kind of error too Thanks ! Link to comment Share on other sites More sharing options...
Community On Patrol Posted September 25, 2008 Share Posted September 25, 2008 Hi Jac, Doing a search of your topic, it's been found many times with the search feature or is listed as a non-descriptive topic. Please do a search before posting new thread topics. And please use descriptive topics so that others that do use the search feature may also find what they are seeking. (You'll also find that using descriptive topics, will get people in your thread that know how to answer your questions, those same people ignore non-descriptive topics). Thanks. Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 25, 2008 Share Posted September 25, 2008 I have a script that run when user logon and sometime i get this errorLine -1:Error: The requested action with this object has failedHow can i debug that kind of error ?Is it possible that user don't see that kind of error tooThanks !If you are making COM object calls of your own in the script, then add a COM error handler (see help file).If you have IE.au3 included in your script, add _IEErrorHandlerRegister() to it (see help file).You can also run the script from SciTE for testing so errors like that go to the console with much more detail. 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...
Jac Posted September 25, 2008 Author Share Posted September 25, 2008 If you are making COM object calls of your own in the script, then add a COM error handler (see help file).If you have IE.au3 included in your script, add _IEErrorHandlerRegister() to it (see help file).You can also run the script from SciTE for testing so errors like that go to the console with much more detail. Ok thanks for the tip i ran the script on the computer that have the error and here is the output of the errorThe requested action with this object has failed.:$HD = $pcinfo & String(Round((Number($object.TotalSize) / (1024 * 1024 * 1024)), 2)) & " Gb \ " & String(Round((Number($object.FreeSpace) / (1024 * 1024 * 1024)), 2))$HD = $pcinfo & String(Round((Number($object.TotalSize^ ERROR->12:57:19 AutoIT3.exe ended.rc:1>Exit code: 1 Time: 4.654Here is the function$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")$DirInventaire = @WorkingDir & "\"$NOM_PC = @ComputerName & ".txt"$NOM_PC = $DirInventaire & $NOM_PC;Drive$objFSO = ObjCreate("Scripting.FileSystemObject")$colDrives = $objFSO.DrivesFor $object In $colDrives IF $object.DriveType == 1 Then $RemovableDrive = "Removable Drive" IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$RemovableDrive) $RemovableDrive = "" ElseIf $object.DriveType == 2 Then $HD = $pcinfo & String(Round((Number($object.TotalSize) / (1024 * 1024 * 1024)), 2)) & " Gb \ " & String(Round((Number($object.FreeSpace) / (1024 * 1024 * 1024)), 2)) IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$HD) ElseIf $object.DriveType == 3 Then $MapDrive = "Map Drive to " & DriveMapGet($object.DriveLetter & ":") IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$MapDrive) $MapDrive = "" ElseIf $object.DriveType == 4 Then $Opticaldrives = "CD-ROM" IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$Opticaldrives) $Opticaldrives = "" EndIfNextOn all my other pc (around 200 ) i have no problemCan it help you ?Thanks! Link to comment Share on other sites More sharing options...
Jac Posted September 25, 2008 Author Share Posted September 25, 2008 Ok thanks for the tip i ran the script on the computer that have the error and here is the output of the errorThe requested action with this object has failed.:$HD = $pcinfo & String(Round((Number($object.TotalSize) / (1024 * 1024 * 1024)), 2)) & " Gb \ " & String(Round((Number($object.FreeSpace) / (1024 * 1024 * 1024)), 2))$HD = $pcinfo & String(Round((Number($object.TotalSize^ ERROR->12:57:19 AutoIT3.exe ended.rc:1>Exit code: 1 Time: 4.654Here is the function$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")$DirInventaire = @WorkingDir & "\"$NOM_PC = @ComputerName & ".txt"$NOM_PC = $DirInventaire & $NOM_PC;Drive$objFSO = ObjCreate("Scripting.FileSystemObject")$colDrives = $objFSO.DrivesFor $object In $colDrives IF $object.DriveType == 1 Then $RemovableDrive = "Removable Drive" IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$RemovableDrive) $RemovableDrive = "" ElseIf $object.DriveType == 2 Then $HD = $pcinfo & String(Round((Number($object.TotalSize) / (1024 * 1024 * 1024)), 2)) & " Gb \ " & String(Round((Number($object.FreeSpace) / (1024 * 1024 * 1024)), 2)) IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$HD) ElseIf $object.DriveType == 3 Then $MapDrive = "Map Drive to " & DriveMapGet($object.DriveLetter & ":") IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$MapDrive) $MapDrive = "" ElseIf $object.DriveType == 4 Then $Opticaldrives = "CD-ROM" IniWrite($NOM_PC,"HARDWARE",$object.DriveLetter & ":\" ,$Opticaldrives) $Opticaldrives = "" EndIfNextOn all my other pc (around 200 ) i have no problemCan it help you ?Thanks!Ive had the function $oMyError = ObjEvent("AutoIt.Error", "ComError");COM Error functionFunc ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0EndFuncAnd now i dont get any error messageThanks ! Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 25, 2008 Share Posted September 25, 2008 (edited) Ive had the function $oMyError = ObjEvent("AutoIt.Error", "ComError") ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc And now i dont get any error message Thanks ! Well, you don't SEE the error because you are handling it. Unless you test for @error <> 0 after that call, you'll never know it happened, but it did. To see the error (assuming you want to) modify the error handler: ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) MsgBox(16, "COM Error!", "$HexNumber = " & $HexNumber) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;==>ComError If you want to find the actual problem, you'll have to dig into why that machine has drives that don't have the .TotalSize property (perhaps a different OS or SP level). Edited September 25, 2008 by PsaltyDS 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...
Jac Posted September 25, 2008 Author Share Posted September 25, 2008 Well, you don't SEE the error because you are handling it. Unless you test for @error <> 0 after that call, you'll never know it happened, but it did. To see the error (assuming you want to) modify the error handler: ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) MsgBox(16, "COM Error!", "$HexNumber = " & $HexNumber) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc;==>ComError If you want to find the actual problem, you'll have to dig into why that machine has drives that don't have the .TotalSize property (perhaps a different OS or SP level). Ok great idea ! Thanks ! 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