Briandr

script question

5 posts in this topic

#1 ·  Posted (edited)

; Generated by AutoIt Scriptomatic

#include <File.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <_ProgressGUI.au3>

Dim $ChassisType, $Model, $ErrorCode, $i

$LogDirectory = @WindowsDir & "\Dell"
$ModuleName = @ScriptName
$ModuleName = StringSplit($ModuleName, ".")
$ModuleName = $ModuleName[1]
$Log = $LogDirectory & "\" & $ModuleName & ".log"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$StrComputer = "localhost"

If Not FileExists($LogDirectory) Then DirCreate($LogDirectory) ;Creates path if does not exist
If FileExists($Log) Then FileDelete($Log)

_FileWriteLog($Log, $ModuleName & " module called.")
_Win32_ComputerSystem() ;Get Model

;Detect and block legacy devices from being imaged
 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
 $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

 While 1
 $i = 0

 If $errorCode <> 0 Then
            ExitLoop
 ElseIf $model = "HP EliteBook Folio 1040 G3" Then
            $Return = _ProgressGUI("Device not on the PC Roadmap. Connect a supported device", 1, 14, "", 307, 120);, 4, 6)
            BlockInput(0)
            Sleep(1000)
   Else
            ExitLoop
   EndIf
   $i = $i + 1
   Wend
   BlockInput(0)

 Func _Win32_ComputerSystem()
    ;Get General PC Info
    $objWMIService = ObjGet("winmgmts:\\" & $StrComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            ;$DOMAIN = $objItem.Domain
            $Manufacturer = $objItem.Manufacturer
            $Model = $objItem.Model
            _FileWriteLog($Log, "Model: " & $Model)
            ;$MachineName = $objItem.Name
            ;$NumberOfProcessors = $objItem.NumberOfProcessors
            ;$PartOfDomain = $objItem.PartOfDomain
            ;$MEM = Round($objItem.TotalPhysicalMemory / 1024 / 1024, 0)
        Next
    EndIf
 EndFunc   ;==>_Win32_ComputerSystem

I have two questions. The first of which has to do with the loop code when a model is detected. Does this look right as I hacked it together? I can show you the source code, if need be.  It should stay on the screen indefinitely. The other thing is can have the actual model show up in the message box? Is there any way to have that auto populate. Hope what I am asking makes sense.

Thanks

Edited by Briandr

Share this post


Link to post
Share on other sites



ElseIf $model = "HP EliteBook Folio 1040 G3" Then
            $Return = _ProgressGUI("Detected device is " & $model. "Connect a supported device", 1, 14, "", 307, 120);, 4, 6)

Can someone tell me if what I am trying to do is even do able. I am thinking its not, but a little help would be appreciated. I am checking into using a msgbox, but would appreciate a little help.

Thanks

Share this post


Link to post
Share on other sites

I am not sure people understand what you are asking.   It may be better to describe what is not working for you from your original post and what you are trying to do (in words not code because the code needs some work).  When you ask about the whether or not the while loop will stay on the screen indefinitely ... I assume you mean the progress bar (why would you want that?).  If you mean you always want the while loop to run then your while loop seems like it will exit if there is no error or if the model is not:

"HP EliteBook Folio 1040 G3"

As an aside, I am not sure why you are tracking the loops with $i as you don't seem to be using that anywhere.

On your second question, you are asking about "the message box" but I don't see a message box in your code.  If you want to display the model in a message box just pass the model variable as the text argument. 

MsgBox(0,"This is the model",$model)

You also use blockinput with the 0 parameter which means don't block input.  I am not sure why you have that.  There are many more examples of things that you would need to address but I think starting with the explanation of what you want to have happen would be a good first step.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

When I hack code together my goal is to get it working, learn as I go and clean it up as I go. A script guy I don't profess to be. Just looking for help. Thanks for the ideas

Share this post


Link to post
Share on other sites

I understand but to the extent you are asking for help you may need to supply more information to get it.  Did you read my previous post?  You still haven't explained what you are trying to do or what problems you are experiencing specifically.  If can do that I am confident you will be better advice that is tailored to your issues.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now