3deepu Posted June 18, 2012 Posted June 18, 2012 Hi there, This is my first post on the forum and has only recently starting using Autoit. I have created fairly simple script that gets the model no of the machine the script is running on using wni_computersytem and then runs the corresponding batch script to dump a ghost image. it seems to run on all the machines except 2 dell machines where it go through the first part but then does not do the second part. i have copied a sample of the script below, could you please advise why is this happening. The problem is with the model E6400 and D630. It works fine till Choose Drive part and after that when the corresponding button is selected it just exits. Appreciate if someone could advise why this is happening. Thanksforum.txt
water Posted June 18, 2012 Posted June 18, 2012 (edited) I suggest do add some error checking: Global $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!" & $strcomputer & "rootcimv2") If @error or Not IsObj($objWMIService) Then Exit MsgBox(16, "ERROR", "Error " & @error & " accessing WMI!") Global $colSettings = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") If @error or Not IsObj($colSettings) Then Exit MsgBox(16, "ERROR", "Error " & @error & " querying WMI!") MsgBox(64, "Count", "Records found: " & $colSettings.count) Edited June 18, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 18, 2012 Author Posted June 18, 2012 Hi Water, I did as you suggested but it did not give me any errors.
water Posted June 18, 2012 Posted June 18, 2012 I modified my post above to output the number of records found. What do you get? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted June 18, 2012 Posted June 18, 2012 Then you need to insert some debugging statements into your PART and FULL functions to make sure the returned results are what you expect. Something like: ConsoleWrite(">" & $CompName & "<" & @CRLF & ">" & $CompModel & "<" & @CRLF) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 19, 2012 Author Posted June 19, 2012 (edited) after the above line is added to the functions, the script outputs the machine name and model on other machines but there is no output on D630. Is there a way we can do line wise execution of the script like we get for Autoexec file. Thanks Edited June 19, 2012 by 3deepu
water Posted June 19, 2012 Posted June 19, 2012 No output at all or just >< >< My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted June 19, 2012 Posted June 19, 2012 Is there a way we can do line wise execution of the script like we get for Autoexec file.To see which statements are executed add#AutoIt3Wrapper_Run_Debug_Mode=Yat the top of your script and run the script from SciTE. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 19, 2012 Author Posted June 19, 2012 what will the statement do. because when run under SciTE, it just runs as normal script.
water Posted June 19, 2012 Posted June 19, 2012 If you run the Script in Debug mode you get this on the Scite console pane: >Running:(3.3.8.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Temp\test.au3" !> Starting in DebugMode.. Line: @error-@extended: Line syntax 0001: 0-0: #AutoIt3Wrapper_Run_Debug_Mode=Y 0002: 0-0: Dim $strcomputer = "." 0003: 0-0: Dim $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strcomputer & "\root\cimv2") 0004: 0-0: Dim $colSettings = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 0006: 0-0: $var = MsgBox(4, "Choose Drive", "Select YES to choose C Drive Imaging") 0007: 0-0: If $var = 6 Then PART() 0008: 0-0: If $var = 7 Then FULL() 0029: 0-0: For $objComputer In $colSettings 0030: 0-0: $CompName = $objComputer.Name 0031: 0-0: $CompModel = $objComputer.Model 0032: 0-0: Next 0033: 0-0: ConsoleWrite(">" & $CompName & "<" & @CRLF & ">" & $CompModel & "<" & @CRLF) >Cxxxx< >HP Compaq dc5800 Microtower< 0039: 0-0: If $CompModel = "Latitude E6420" Then RunWait(@ScriptDir & "\6420F.bat", @ScriptDir, @SW_MAXIMIZE) 0040: 0-0: If $CompModel = "Latitude E6410" Then RunWait(@ScriptDir & "\6410F.bat", @ScriptDir, @SW_MAXIMIZE) 0041: 0-0: If $CompModel = "Latitude E6400" Then RunWait(@ScriptDir & "\6400F.bat", @ScriptDir, @SW_MAXIMIZE) 0042: 0-0: If $CompModel = "Latitude D630" Then RunWait(@ScriptDir & "\D630F.bat", @ScriptDir, @SW_MAXIMIZE) 0044: 0-0: EndFunc ;==>FULL 0010: 0-0: Func PART() 0028: 0-0: Func FULL() 0045: 0-0: #cs +>09:56:57 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 3.175 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 19, 2012 Author Posted June 19, 2012 I found the problem, what happens is that when the computer model is read from the system by the script, it outputs it as >Latitude D630 < instead of >Latitutde D630<. this extra space is causing the problem. any way of removing this when it outputs or else will have to copy the exact no of spaces into the script. thanks
water Posted June 19, 2012 Posted June 19, 2012 Use$CompModel = StringStripWS($CompModel, 3)to remove leading and trailing spaces. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 20, 2012 Author Posted June 20, 2012 Thanks Water, the script is working fine. i had another little query, what if I need to put a wildcard on the CompModel.
water Posted June 20, 2012 Posted June 20, 2012 You could use functions StringLeft, StringMid, StringInStr or even Regular Expressions to check for a substring. Wildcards can only be used with regular expressions (as far as I know).Do you have an example what you want to look for? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
3deepu Posted June 20, 2012 Author Posted June 20, 2012 for e.g. i have a model 6974WDX and 6974WWN the ghost images for both models are the same , so I was wondering if I could use "6474*" instead of the specific models. Another question, can i have all these models listed in a db along with their respective scripts and not enter these specific lines in the script itself. e.g. it will check for the model against the list of models in a db and then apply the appropriate script. sorry to bombard you with these querries but the more I am using Autoit the more I am liking it. also I am impressed with your response.
water Posted June 20, 2012 Posted June 20, 2012 Ad 1) Something like If StringLeft($CompModel, 4) = "6974" Then ... Ad 2) It's possible but needs more work. You need to access the DB and extract the data. You need another script to maintain the data in the DB. A DB only makes sense when a lot of people/PCs should access the same data that changes often. You could use INI files and read the content to an array. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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