Sign in to follow this  
Followers 0
joshiieeii

Xp Automation Apps

10 posts in this topic

Hi guys, first post I think, anyway, I am trying to create a two applications:

These apps will be used for automating the deployment of PC's. I am going to create 3 different images, boot the target PC's with WinPE (which will hopefully run App2) and automate the process.

App1: Prompts user a series of questions and places those profiles in some form of text file (ini, csv....)

ex. Username, Type of PC, make of PC, PC Model, Applications selected

App2: Checks for network, maps a drive, reads above said file and prompts the operator to chose ONE of the profiles. After choosing the profile, and confirming the selection would 1)prompt WinPE to ghost an image to the HD then 2)after ghosting, edit a couple files and restart the machine.

I need some help with app2 (actually the entire thing, but I will settle for app2 for now). I am trying to figure out the best way to store the data in some type of text file (either ini or csv or something) and display (potential for max 50 profiles) this in a selection type way (which will only allow one choice and confirm that).

Thank you for any advice/help you can provide!! :(

I am still learning, so forgive my newb code :think:

#include <GUIConstants.au3>
#include <file.au3>

GUICreate ( "App2", 1024, 768)
GUISetState (@SW_SHOW)    ; will display an empty dialog box
GUICtrlCreateLabel ( "Network Status:", 10, 10, 150)
GUICtrlCreateLabel ( "Drive Mapped:", 300, 10, 150)
GUICtrlCreateLabel ( "Autoconfig File Accessable:", 600, 10, 150)

Dim $autconfigrecords

Call ("BeginProcess")

func BeginProcess ()
Call ("netping")
Call ("MntDrvX")
call ("VerifyNVfile")
Call ("ReadAutoconfig")

EndFunc

$autoconfig = fileopen ( "X:\autoconfig\autoconfig.ini", 0)


;Check network status
Func netping ()
$netvar = ping("10.10.10.100", 200);Pings local site to verify network connectivity
If $netvar Then; also possible:  If @error = 0 Then ...
    GUICtrlCreateLabel ( "Network Status: CONFIRMED", 10, 10, 250)
    GUICtrlSetBkColor(-1,0x00ff00)
    GUIGetMsg()
;call ("MntDrvX");Mounts network drive that has the ghost images and other automation scripts   
Else
    GUICtrlCreateLabel ( "Network Status: NOT AVAILABLE", 10, 10, 250)
    GUICtrlSetBkColor(-1,0xff0000)
    GUIGetMsg()
    call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
EndIf
EndFunc 

;Mount drive
Func MntDrvX ()
    DriveMapAdd("X:", "\\10.10.10.100\NVPESHARE");network share that has the ghost images and other automation scripts
    $drvstat = DriveStatus( "x:\" )
    If $drvstat = ("INVALID")Then 
            MsgBox(4096,"Status",$drvstat)
    GUICtrlCreateLabel ( "Drive Mapped: NOT Able to MAP", 300, 10, 250);verifies that drive is mapped
    GUICtrlSetBkColor(-1,0xff0000)
    GUIGetMsg()
Else
    GUICtrlCreateLabel ( "Drive Mapped: Confirmed", 300, 10, 250)
    GUICtrlSetBkColor(-1,0x00ff00)
    GUIGetMsg()
;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
   ;gives an error message that drive is not mapped
EndIf
EndFunc

;Verify that file exists
Func VerifyNVfile ();Verfies existence of the autoconfig file
If FileExists ( "X:\autoconfig\autoconfig.ini")then
    GUICtrlCreateLabel ( "Autoconfig File Accessable: CONFIRMED", 600, 10, 250)
    GUICtrlSetBkColor(-1,0x00ff00)
    GUIGetMsg()
Else
    GUICtrlCreateLabel ( "Autoconfig File Accessable: NOT AVAILABLE", 600, 10, 250)
    GUICtrlSetBkColor(-1,0xff0000)  
    GUIGetMsg()
;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
EndIf
 EndFunc
 
 
func terminate ()
GUICreate ( "Network not available: RETRY??",400, 100, -1, -1)
$termok = GUICtrlCreateButton ("OK",  50, 30, 100)
$termcan = GUICtrlCreateButton ( "Cancel",  200, 30, 100)
GUISetState ()     
If $termok = 1 Then
    Call ("BeginProcess")
EndIf

if $termcan = 1 Then
    MsgBox ( 4096, "cancelled", "Terminated" )
EndIf
EndFunc


Func ReadAutoconfig ()

If Not _FileReadToArray("X:\autoconfig\autoconfig.ini",$autconfigrecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Else
      For $x = 2 to $autconfigrecords[0]

   GUICtrlCreateGroup ("User Deployment", 190, 60, 500, 140)
$radio_1 = GUICtrlCreateRadio ( ""& $autconfigrecords[$x], 210, 90, 300, 20)
;GUICtrlSetState ($radio_1,$GUI_CHECKED)
;$radio_2 = GUICtrlCreateRadio ( ""& $autconfigrecords[$x], 210, 110, 300, 50)
;$radio_3 =
;$radio_4 =
;$radio_5 =
;$radio_6 =
;$radio_7 =
;$radio_8 =
;$radio_9 =
;$radio_10 =
GUISetState ()    ; will display an  dialog box with 1 checkbox

GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState () 
Next
     
EndIf


EndFunc

sleep (3000)

Share this post


Link to post
Share on other sites



In the help files look at iniread and iniwrite, those should be able to do everything for you


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

In the help files look at iniread and iniwrite, those should be able to do everything for you

I already knew how to do that, but how would I get the entries to show up in my gui for selection?

In Addition, how would someone be able to select a particular user from the list of entries??

Edited by joshiieeii

Share this post


Link to post
Share on other sites

I already knew how to do that, but how would I get the entries to show up in my gui for selection?

In Addition, how would someone be able to select a particular user from the list of entries??

Use a combobox?
$Blah = IniReadSection('FileLocation', 'Section For Combo')
$TempHold = ''
For $i = 1 To $Blah[0][0]
    $TempHold &= $Blah[$i][0] & '|'
Next
$TempHold = StringTrimRight($TempHold, 1)
GUICtrlSetData($Combo, $TempHold)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Use a combobox?

$Blah = IniReadSection('FileLocation', 'Section For Combo')
$TempHold = ''
For $i = 1 To $Blah[0][0]
    $TempHold &= $Blah[$i][0] & '|'
Next
$TempHold = StringTrimRight($TempHold, 1)
GUICtrlSetData($Combo, $TempHold)
It's going to take me awhile to get this worked in, but I will give it a whirl tonight....Would you do a Do..While loop or something if there were like 10 seperate entries??

Share this post


Link to post
Share on other sites

It's going to take me awhile to get this worked in, but I will give it a whirl tonight....Would you do a Do..While loop or something if there were like 10 seperate entries??

Afraid I don't understand your question.

It's already in a For/Next loop if that's what you mean.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

cleaned your code just a little

#include <GUIConstants.au3>
#include <file.au3>

GUICreate("App2", 1024, 768)
GUISetState(@SW_SHOW)    ; will display an empty dialog box
GUICtrlCreateLabel("Network Status:", 10, 10, 150)
GUICtrlCreateLabel("Drive Mapped:", 300, 10, 150)
GUICtrlCreateLabel("Autoconfig File Accessable:", 600, 10, 150)

Dim $autconfigrecords, $radio_[11]

Call("BeginProcess")

Func BeginProcess()
    Call("netping")
    Call("MntDrvX")
    Call("VerifyNVfile")
    Call("ReadAutoconfig")
    
EndFunc  ;==>BeginProcess 

$autoconfig = FileOpen("X:\autoconfig\autoconfig.ini", 0)

While 1
    $msg = GUIGetMsg()
WEnd

;Check network status
Func netping()
    $netvar = Ping("10.10.10.100", 200);Pings local site to verify network connectivity
    If $netvar Then; also possible:  If @error = 0 Then ...
        GUICtrlCreateLabel("Network Status: CONFIRMED", 10, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
    ;call ("MntDrvX");Mounts network drive that has the ghost images and other automation scripts
    Else
        GUICtrlCreateLabel("Network Status: NOT AVAILABLE", 10, 10, 250)
        GUICtrlSetBkColor(-1, 0xff0000)
        
        Call("terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
    EndIf
EndFunc  ;==>netping 

;Mount drive
Func MntDrvX()
    DriveMapAdd("X:", "\\10.10.10.100\NVPESHARE");network share that has the ghost images and other automation scripts
    $drvstat = DriveStatus( "x:\")
    If $drvstat = ("INVALID") Then
        MsgBox(4096, "Status", $drvstat)
        GUICtrlCreateLabel("Drive Mapped: NOT Able to MAP", 300, 10, 250);verifies that drive is mapped
        GUICtrlSetBkColor(-1, 0xff0000)
        
    Else
        GUICtrlCreateLabel("Drive Mapped: Confirmed", 300, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
    ;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
    ;gives an error message that drive is not mapped
    EndIf
EndFunc  ;==>MntDrvX 

;Verify that file exists
Func VerifyNVfile();Verfies existence of the autoconfig file
    If FileExists("X:\autoconfig\autoconfig.ini") Then
        GUICtrlCreateLabel("Autoconfig File Accessable: CONFIRMED", 600, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
    Else
        GUICtrlCreateLabel("Autoconfig File Accessable: NOT AVAILABLE", 600, 10, 250)
        GUICtrlSetBkColor(-1, 0xff0000)
        
    ;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
    EndIf
EndFunc  ;==>VerifyNVfile 


Func terminate()
    #Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK and Cancel, Icon=Question, Miscellaneous=Top-most attribute
If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(262177,"Network Error","Network not available: RETRY??     ")
Select
   Case $iMsgBoxAnswer = 1;OK
        Call("BeginProcess")
   Case $iMsgBoxAnswer = 2;Cancel
        MsgBox(4096, "cancelled", "Terminated", 1)
EndSelect
#EndRegion --- CodeWizard generated code End ---

    #cs
    GUICreate("Network not available: RETRY??", 400, 100, -1, -1)
    $termok = GUICtrlCreateButton("OK", 50, 30, 100)
    $termcan = GUICtrlCreateButton("Cancel", 200, 30, 100)
    GUISetState()
    
    While 2
        $msg2 = GUIGetMsg()
        
        If $msg2 = $termok Then 
            Call("BeginProcess")
            Return
        EndIf
    
        If $msg2 = $termcan Then 
            MsgBox(4096, "cancelled", "Terminated", 2)
            ExitLoop
        EndIf
    WEnd
    #ce
EndFunc  ;==>terminate 


Func ReadAutoconfig()
    
    If Not _FileReadToArray("X:\autoconfig\autoconfig.ini", $autconfigrecords) Then
        MsgBox(4096, "Error", " Error reading log to Array   error:" & @error)
        GUISetState()
        Return
    Else
        $top = 90
        GUICtrlCreateGroup("User Deployment", 190, 60, 500, 140)
        For $x = 2 To $autconfigrecords[0]
            
            $radio_[$x] = GUICtrlCreateRadio("" & $autconfigrecords[$x], 210, $top, 300, 20)
            If $x = 2 Then GUICtrlSetState($radio_[2], $GUI_CHECKED)
            $top = $top + 30
            
        Next
        GUICtrlCreateGroup("", -99, -99, 1, 1);close group
        GUISetState()    ; will display an  dialog box with 1 checkbox
    EndIf
    
    
EndFunc  ;==>ReadAutoconfig

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Ok, so I have been playing with the code some more, and have customized it some more.

Now I am running into a situation where I am not having any luck with the help file finding out how to get the selected user into a variable.

Also, if I am seperating the data for the users by using a series of ";;", how would I pull individual data pieces? ex. username;;PCType;;PCMake;;PCModel;;Apps

Would I be better off using the iniwrite style?

ex.

[section]

key=value

Trying to use the simpliest method. Once the user is selected from the ini file, I want to display the info in a Gui to the right of the selection and have a "Deploy" button to start the process. Based on the User selected, the "Deploy" button would initiate a series of functions based on the info in the user's profile. So if the make was a Dell>D800 then it would edit a file to include those apps, if the profile has MS Visio, MS Frontpage, then do this, ect...

I know what I want to do, I just can't find the method to employ these ideas just based off of the Help file. Thanks for any help!!

:think:

#include <GUIConstants.au3>
#include <file.au3>

GUICreate("App2", 1024, 768)
GUISetState(@SW_SHOW); will display an empty dialog box
GUICtrlCreateLabel("Network Status:", 10, 10, 150)
GUICtrlCreateLabel("Drive Mapped:", 300, 10, 150)
GUICtrlCreateLabel("Autoconfig File Accessable:", 600, 10, 150)

Dim $autconfigrecords, $radio_[28]
Dim $selectedUser

Call("BeginProcess")

Func BeginProcess()
    Call("netping")
    Call("MntDrvX")
    Call("VerifyNVfile")
    Call("ReadAutoconfig")
;Call("DisplayUser")
    
    
EndFunc;==>BeginProcess 

$autoconfig = FileOpen("X:\autoconfig\autoconfig.ini", 0)

While 1
    $msg = GUIGetMsg()
WEnd

;Check network status
Func netping()
    $netvar = Ping("10.10.10.100", 200);Pings local site to verify network connectivity
    If $netvar Then; also possible:  If @error = 0 Then ...
        GUICtrlCreateLabel("Network Status: CONFIRMED", 10, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
  ;call ("MntDrvX");Mounts network drive that has the ghost images and other automation scripts
    Else
        GUICtrlCreateLabel("Network Status: NOT AVAILABLE", 10, 10, 250)
        GUICtrlSetBkColor(-1, 0xff0000)
        
        Call("terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
    EndIf
EndFunc;==>netping 

;Mount drive
Func MntDrvX()
    DriveMapAdd("Z:", "\\10.10.10.100\NVPESHARE");network share that has the ghost images and other automation scripts
    $drvstat = DriveStatus( "Z:\")
    If $drvstat = ("INVALID") Then
        MsgBox(4096, "Status", $drvstat)
        GUICtrlCreateLabel("Drive Mapped: NOT Able to MAP", 300, 10, 250);verifies that drive is mapped
        GUICtrlSetBkColor(-1, 0xff0000)
        
    Else
        GUICtrlCreateLabel("Drive Mapped: Confirmed", 300, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
  ;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
  ;gives an error message that drive is not mapped
    EndIf
EndFunc;==>MntDrvX 

;Verify that file exists
Func VerifyNVfile();Verfies existence of the autoconfig file
    If FileExists("Z:\autoconfig\autoconfig.ini") Then
        GUICtrlCreateLabel("Autoconfig File Accessable: CONFIRMED", 600, 10, 250)
        GUICtrlSetBkColor(-1, 0x00ff00)
        
    Else
        GUICtrlCreateLabel("Autoconfig File Accessable: NOT AVAILABLE", 600, 10, 250)
        GUICtrlSetBkColor(-1, 0xff0000)
        
  ;call ("Terminate");Calls a function to prompt the user to terminate the session as the network connection does not exist
    EndIf
EndFunc;==>VerifyNVfile 


Func terminate()
    #Region --- CodeWizard generated code Start ---
;MsgBox features: Title=Yes, Text=Yes, Buttons=OK and Cancel, Icon=Question, Miscellaneous=Top-most attribute
If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(262177,"Network Error","Network not available: RETRY??     ")
Select
   Case $iMsgBoxAnswer = 1;OK
        Call("BeginProcess")
   Case $iMsgBoxAnswer = 2;Cancel
        MsgBox(4096, "cancelled", "Terminated", 1)
EndSelect
#EndRegion --- CodeWizard generated code End ---

    #cs
    GUICreate("Network not available: RETRY??", 400, 100, -1, -1)
    $termok = GUICtrlCreateButton("OK", 50, 30, 100)
    $termcan = GUICtrlCreateButton("Cancel", 200, 30, 100)
    GUISetState()
    
    While 2
        $msg2 = GUIGetMsg()
        
        If $msg2 = $termok Then 
            Call("BeginProcess")
            Return
        EndIf
    
        If $msg2 = $termcan Then 
            MsgBox(4096, "cancelled", "Terminated", 2)
            ExitLoop
        EndIf
    WEnd
    #ce
EndFunc;==>terminate 


Func ReadAutoconfig()
    
    If Not _FileReadToArray("Z:\autoconfig\autoconfig.ini", $autconfigrecords) Then
        MsgBox(4096, "Error", " Error reading log to Array   error:" & @error)
        GUISetState()
        Return
    Else
        $top = 90
        GUICtrlCreateGroup("User Deployment", 30, 60, 350, 640)
        For $x = 2 To $autconfigrecords[0]
            
            $radio_[$x] = GUICtrlCreateRadio("" & $autconfigrecords[$x], 60, $top, 300, 20)
            If $x = 2 Then GUICtrlSetState($radio_[2], $GUI_CHECKED)
            $top = $top + 30
            
        Next
        GUICtrlCreateGroup("", -99, -99, 1, 1);close group
        GUISetState(); will display an  dialog box with 1 checkbox
    EndIf
 $selectuser = GUICtrlCreateButton ( "Select User", 30 , 710, 350, 30)
GUISetState ()

While 1
   $msg = GUIGetMsg()
   Select
       Case $msg = $selectuser
          MsgBox(0, "Default button clicked", "User:" & $autconfigrecords [3] )
      Case $msg = $GUI_EVENT_MINIMIZE
         MsgBox(0,"", "Dialog minimized",2)
      Case $msg = $GUI_EVENT_MAXIMIZE
         MsgBox(0,"", "Dialog restored",2)
   


   EndSelect
WEnd
    
EndFunc;==>ReadAutoconfig
Edited by joshiieeii

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
Sign in to follow this  
Followers 0