Jump to content

namdog

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by namdog

  1. I ended up finding a workaround though it's not preferable. I had to compile each function into a separate .exe files. Doing this and having the initial script calling these separate .exe files appears to work. It is a little slower, but it works. I'll keep a look out for future Excel updates. Thanks again for your help.
  2. The updates seem to have taken care of the initial problem. However now, it's failing when calling the _Excel_RangeRead during the 4th function call, even when using the same workbook. Any suggestions? someprogram_Test.au3" (289) : ==> The requested action with this object has failed.: $numList = _Excel_RangeRead($mWorkbook, $mWorkbook.Sheets("Users")) $numList = _Excel_RangeRead($mWorkbook, $mWorkbook^ ERROR
  3. I'm wondering if there's a known bug with the _Excel_BookOpen function? I'm using Excel to automate reports. In short, this program will read through spreadsheets, copy the data from those opened then paste to a master workbook for a remote site. There are 5 remote sites right now that we need to run these reports on. I have a function that will read the name of the report, then dump the data into the master workbook.sheets("report name"), concatenate, copy that data to the Users sheet, remove all duplicates and sort, then copy to the Master List sheet in that workbook. Essentially showing who at that site has access using embedded Excel formulas. There could be anywhere from 5-20 reports per site. Regardless of how I set this up, I'm running into the same error: "C:\Program Files (x86)\AutoIt3\Include\Excel.au3" (227) : ==> Variable must be of type "Object".: $oExcel.Windows($oWorkbook.Name).Visible = $bVisible $oExcel.Windows($oWorkbook.Name)^ ERROR This is pointing back to the _Excel_BookOpen function, however, I cannot find a way around this. Initially, I thought this may be due to the workbook I was attempting to open, but it is not. I tested this theory by calling the same function with the same parameters multiple times and received the exact same output. It will run through for the first 3 function calls, but when it gets to Site4, it fails 3 reports in. Memory usage and processor usage are normal and are not spiking and nomenclatures are correct. I am also clearing the clipboard in between calls. I have included a snippet of the code, but due to company policy, I cannot include any of the excel documents. I know this is long winded, but any suggestions would be greatly appreciated. reports.au3
  4. For those who are interested, the problem was with the nested while loop. Created functions to house the while loops. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> ;Description: Allows the user to connect to the specified VM's. If the user was previously connected to a VM ;and didn't log off, it will reconnect them. $tempfile = "C:\temp\loggedon.log" $nologgedon = "INFO: No tasks are running which match the specified criteria." $username = "User Name: DOMAIN\" ;Change the DOMAIN (PLACE IN ALL CAPS) Dim $line Dim $currentMachinePointer Dim $hasFoundPreviousHost Dim $hasFoundAvailableHost $GUI_Size=100 $GUITitle="VM Launcher" $GUIWording=("Searching." & @CRLF & "Please wait...") GUICreate ($GUITitle, 200, $GUI_Size) $Label = GUICtrlCreateLabel($GUIWording,80,30) $numberOfHostMachines = 3 ; Change to match the number of $hostMachines Dim $hostMachines[$numberOfHostMachines] ;Place PC names here $hostMachines[0] = "x" $hostMachines[1] = "y" $hostMachines[2] = "z" Func findPreviousHost() $currentMachinePointer = 0 $hasFoundPreviousHost = False While (($currentMachinePointer < $numberOfHostMachines) and Not($hasFoundPreviousHost)) GUISetState(@SW_SHOW) ;Show initial installation GUI window Do $possibleHost = $hostMachines[$currentMachinePointer] ;~ MsgBox(0,"Test1",$possibleHost) ;~ MsgBox(0,"PointerTest1",$currentMachinePointer) If checkPreviousLogin($possibleHost) Then $hasFoundPreviousHost = True $hasFoundAvailableHost = True ExitLoop(2) Else $currentMachinePointer = $currentMachinePointer + 1 EndIf Until $currentMachinePointer = $numberOfHostMachines ExitLoop WEnd EndFunc Func findAvailableHost() $currentMachinePointer = 0 $hasFoundAvailableHost = False While (($currentMachinePointer < $numberOfHostMachines) and Not($hasFoundAvailableHost)) Do $possibleHost = $hostMachines[$currentMachinePointer] ;~ MsgBox(0,"Test2",$possibleHost) ;~ MsgBox(0,"PointerTest2",$currentMachinePointer) If isComputerAvailable($possibleHost) Then $hasFoundAvailableHost = True ExitLoop(2) Else $currentMachinePointer = $currentMachinePointer + 1 EndIf Until $currentMachinePointer = $numberOfHostMachines ExitLoop WEnd EndFunc findPreviousHost() If $hasFoundPreviousHost Then connectToHost($hostMachines[$currentMachinePointer]) Else MsgBox(0,"Don't worry","Not currently logged into any systems", 2) EndIf If Not $hasFoundPreviousHost Then findAvailableHost() If $hasFoundAvailableHost Then connectToHost($hostMachines[$currentMachinePointer]) Else MsgBox(0,"Bad News","No available machine to connect to") EndIf EndIf Func checkPreviousLogin($hostName) $isAvailable = False RunWait(@COMSPEC & " /c " & 'tasklist /v /fo list /fi "IMAGENAME eq explorer.exe" /s \\' & $hostName & ' > ' & $tempfile,"",@SW_HIDE) ; Might need to do RunAsWait with credentials If $tempfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $user = ($username & @UserName) $vmline = FileReadLine($tempfile, 7) If $vmline = $user Then $isAvailable = True EndIf FileClose($tempfile) return $isAvailable EndFunc Func isComputerAvailable($hostName) $isAvailable = False RunWait(@COMSPEC & " /c " & 'tasklist /v /fo list /fi "IMAGENAME eq explorer.exe" /s \\' & $hostName & ' > ' & $tempfile,"",@SW_HIDE)) ; Might need to do RunAsWait with credentials If $tempfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $line = FileReadLine($tempfile) If @error = -1 Then MsgBox(0, $hostName, $line) If $line = $nologgedon Then $isAvailable = True EndIf FileClose($tempfile) return $isAvailable EndFunc Func connectToHost($hostName) RunWait("C:\Windows\System32\mstsc.exe /v:" & $hostName) EndFunc
  5. I seem to be having an issue and have no idea on how to resolve this. I've only been using AutoIT for about 1 year now. I'm trying to write a program for my company that will remote into 1 of four virtual machines. The criteria should be that if the user is logged in and just closed the RDP session by accident, running this program will log him back into that VM, otherwise it will find the first available VM and connect the user to that. (Similar to VMWare View which costs about $50k for a license) The problem I'm running into is that only one of the "While" loops is working. If I comment one out, the other seems to work fine. Any advice would greatly be appriciated. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;Description: Allows the user to connect to the specified VM's. If the user was previously connected to a VM ;and didn't log off, it will reconnect them. $tempfile = "C:\temp\loggedon.log" $nologgedon = "INFO: No tasks are running which match the specified criteria." $username = "User Name: DOMAIN\" ;Change the DOMAIN (PLACE IN ALL CAPS) Dim $line $numberOfHostMachines = 3 Dim $hostMachines[$numberOfHostMachines] ;Place PC names here $hostMachines[0] = "x" $hostMachines[1] = "y" $hostMachines[2] = "z" $currentMachinePointer = 0 $hasFoundPreviousHost = False $hasFoundWorkingHost = False $hasFoundAvailableHost = False While (($currentMachinePointer < $numberOfHostMachines) and Not($hasFoundPreviousHost)) $possibleHost = $hostMachines[$currentMachinePointer] MsgBox(0,"Test1",$possibleHost) If checkPreviousLogin($possibleHost) Then $hasFoundPreviousHost = True $hasFoundWorkingHost = True Else while (($currentMachinePointer < $numberOfHostMachines) and Not($hasFoundWorkingHost)) $possibleHost = $hostMachines[$currentMachinePointer] MsgBox(0,"Test2",$possibleHost) If isComputerAvailable($possibleHost) Then $hasFoundWorkingHost = True Else $currentMachinePointer = $currentMachinePointer + 1 EndIf WEnd $currentMachinePointer = $currentMachinePointer + 1 EndIf WEnd while (($currentMachinePointer < $numberOfHostMachines) and Not($hasFoundWorkingHost)) $possibleHost = $hostMachines[$currentMachinePointer] MsgBox(0,"Test3",$possibleHost) If isComputerAvailable($possibleHost) Then $hasFoundAvailableHost = True Else $currentMachinePointer = $currentMachinePointer + 1 EndIf WEnd If $hasFoundPreviousHost Then connectToHost($hostMachines[$currentMachinePointer]) ElseIf $hasFoundWorkingHost Then connectToHost($hostMachines[$currentMachinePointer]) Else MsgBox(0, "Bad News", "No available machines to connect to.") EndIf Func checkPreviousLogin($hostname) $isAvailable = False RunWait(@COMSPEC & " /c " & 'tasklist /v /fo list /fi "IMAGENAME eq explorer.exe" /s \\' & $hostname & ' > ' & $tempfile) If $tempfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $user = ($username & @UserName) $vmline = FileReadLine($tempfile, 7) If $vmline = $user Then $isAvailable = True EndIf FileClose($tempfile) return $isAvailable EndFunc Func isComputerAvailable($hostName) $isAvailable = False RunWait(@COMSPEC & " /c " & 'tasklist /v /fo list /fi "IMAGENAME eq explorer.exe" /s \\' & $hostname & ' > ' & $tempfile) If $tempfile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $line = FileReadLine($tempfile) If @error = -1 Then MsgBox(0, $hostname, $line) If $line = $nologgedon Then $isAvailable = True EndIf FileClose($tempfile) return $isAvailable EndFunc Func connectToHost($hostName) RunWait("C:\Windows\System32\mstsc.exe /v:" & $hostname) EndFunc
×
×
  • Create New...