rikho Posted February 27, 2008 Posted February 27, 2008 Hello all Below is a script can check if a computername is in a *.ini file in TARGET section on a host share. But i dont know how to use a loop with an only one results. if the computer name value is found i want a success message and reset the program to start before click on run. if the value is not found i want an only one error message Can u help me plz ps : sorry for my english i'm french expandcollapse popup#include <GUIConstants.au3> $Form1 = GUICreate("Checker", 143, 174, 193, 115) $Label1 = GUICtrlCreateLabel("Host", 8, 8, 113, 17) $_host = GUICtrlCreateCombo("", 8, 24, 120, 120) GUICtrlSetData($_host, "host1|host2|host3", "") $Label2 = GUICtrlCreateLabel("searchvalue", 8, 48, 119, 17) $value = GUICtrlCreateInput("", 8, 64, 120, 21) ;~ $file = GUICtrlCreateInput ( "", 10, 5, 300, 20) $Label3 = GUICtrlCreateLabel("computername ", 8, 88, 73, 17) $poste = GUICtrlCreateInput("", 8, 104, 120, 21) $run = GUICtrlCreateButton("Run", 8, 136, 51, 25, 0) $Quit = GUICtrlCreateButton("Quit", 72, 136, 59, 25, 0) GUISetState(@SW_SHOW) ;~ Func succes() ;~ ;~ EndFunc Func succes() RunWait(@ComSpec & ' /c net use b: /d', '', @SW_HIDE) Sleep(200) MsgBox(4096, "", "SUCCES : Computer correctly tag with value " & GUICtrlRead($value), 100) EndFunc ;==>succes Func error() RunWait(@ComSpec & ' /c net use b: /d', '', @SW_HIDE) Sleep(200) MsgBox(4096, "", "ERROR : Computer not correctly tag with value " & GUICtrlRead($value), 100) EndFunc ;==>echec Func loop() $host = GUICtrlRead($_host) $cfg_file = GUICtrlRead($value) & '.cfg' $IniPath = '\\' & $host & '\' & 'share$' & '\files' Sleep(200) RunWait(@ComSpec & ' /c net use b: /d', '', @SW_HIDE) Sleep(200) If $host = "host3" Then RunWait(@ComSpec & ' /c net use b: ' & $IniPath & ' domain@pasw /u:domain\admin', '', @SW_HIDE) MsgBox(4096, "", "net use on " & $IniPath & " will be on b: drive" , 100) Else RunWait(@ComSpec & ' /c net use b: ' & $IniPath & ' domain2@pasw /u:domain2\admin', '', @SW_HIDE) MsgBox(4096, "", "net use on " & $IniPath & " will be on b: drive", 100) EndIf Sleep(200) $var = IniReadSection('b:\' & $cfg_file, "TARGET") If @error Then MsgBox(4096, "", "Access file error, please check any persistent connexion on host your trying to connect.") Else EndIf For $i = 1 To $var[0][0] If $var[$i][1] = GUICtrlRead($poste) Then succes() Else error() EndIf Next EndFunc ;==>loop While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Quit Exit Case $nMsg = $run loop() EndSelect WEnd
PsaltyDS Posted February 27, 2008 Posted February 27, 2008 Hello all Below is a script can check if a computername is in a *.ini file in TARGET section on a host share. But i dont know how to use a loop with an only one results. if the computer name value is found i want a success message and reset the program to start before click on run. if the value is not found i want an only one error message Can u help me plz ps : sorry for my english i'm french Just exit the loop once you get success, and use a flag to test for error: $iSuccess = False For $i = 1 To $var[0][0] If $var[$i][1] = GUICtrlRead($poste) Then succes() $iSuccess = True ExitLoop EndIf Next If Not $iSuccess Then error() 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
rikho Posted February 28, 2008 Author Posted February 28, 2008 Just exit the loop once you get success, and use a flag to test for error: $iSuccess = False For $i = 1 To $var[0][0] If $var[$i][1] = GUICtrlRead($poste) Then succes() $iSuccess = True ExitLoop EndIf Next If Not $iSuccess Then error() Thank you very much for help i made it like this then $Boucle = True While $Boucle = True If $var[$i][1] = GUICtrlRead($poste) Then MsgBox(4096, "", "SUCCES : poste ciblé avec le chapeau " & GUICtrlRead($chapeau), 100) $Boucle = False Else $i = $i + 1 If $i > $var[0][0] Then $Boucle = False EndIf EndIf WEnd it work perfectly
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