
SuperFletch
Active Members-
Posts
47 -
Joined
-
Last visited
Everything posted by SuperFletch
-
Change GUI depending on checkbox state
SuperFletch replied to SuperFletch's topic in AutoIt GUI Help and Support
Thanks everyone, Pretty sure I can crack this now - I'll deffo remember to name my controls in future. Cheers. -
Change GUI depending on checkbox state
SuperFletch replied to SuperFletch's topic in AutoIt GUI Help and Support
OK - thanks - here is the full code so far. #include<GuiConstants.au3> #include<Process.au3> ;Tool to gather MAC Addresses of SOLUS 3 Machines and attempt Wake On Lan GUICreate("S3 Wake on Lan Tool",400,400) GUICtrlCreateLabel("This tool will extract agent Mac Addresses listed in the S3 database and",30,30) GUICtrlCreateLabel("broadcast an attempt to wake them.",30,44) GUICtrlCreateLabel("Once run you will need to monitor the S3 GUI to see how well it works.",30,66) GUICtrlCreateLabel("Only desktop machines on a wired ethernet connection are likely to",30,80) GUICtrlCreateLabel("succeed as Wireless network connections rarely support Wake On LAN.",30,94) GUICtrlCreateLabel("To access the S3 database enter the SQL Server and SA password below",30,150) GUICtrlCreateLabel("or enter the SQL Server and choose the Trusted authentication option.",30,164) GUICtrlCreateInput("localhost\sims****",100,185,150) GUICtrlCreateInput("SAPASSWORD",100,215,150) GUICtrlCreateLabel("SQL Server",30,190) GUICtrlCreateLabel("SA Password",30,220) GUICtrlCreateCheckbox("Trusted Auth'",270,215) ;NEED TO MAKE IT SO WHEN CHECKED IT GREYS THE SA PASSWORD BOX OUT $GO = GUICtrlCreateButton("Go",100,240,80,30) $CANCEL = GUICtrlCreateButton("Cancel",200,240,80,30) GUISetState(@SW_SHOWNORMAL) While 1 If GUICtrlRead(14) = 1 then GUICtrlSetState(11,128) Else GUICtrlSetState(11,64) EndIf $Msg = GUIGetMsg() Select Case $Msg=$CANCEL GUIDelete() Exit Case $Msg=$GUI_EVENT_CLOSE GUIDelete() Exit Case $Msg=$GO ExitLoop EndSelect WEnd $Message = GUICtrlRead(14) ;READ THE DATA FROM THE GUI If GUICtrlRead(14) = 1 Then Call("TrustedAuth") Else Call("SQLAuth") EndIf Func SQLAuth() $ServerName=GUICtrlRead(10) $SAPassword=GUICtrlRead(11) ;ADD THE DATA INTO A STRING TO RUN THE SQL COMMAND OUTPUT TO A TEMPORARY FILE $TempFile=(@ScriptDir & "\tempfile.txt") $GetMacs=('osql -S ' & $ServerName & ' -d solus3_deployment_server -U sa -P ' & $SAPassword & ' -Q "SELECT mac_address FROM solus3.agent" -o "' & $TempFile & '"') MsgBox(0,"Code to get Mac Addresses out of S3 DB and into a tempfile","" & $GetMacs) _RunDos($GetMacs) EndFunc Func TrustedAuth() $ServerName=GUICtrlRead(10) ;ADD THE DATA INTO A STRING TO RUN THE SQL COMMAND OUTPUT TO A TEMPORARY FILE $TempFile=(@ScriptDir & "\tempfile.txt") $GetMacs=('osql -S ' & $ServerName & ' -d solus3_deployment_server -E -Q "SELECT mac_address FROM solus3.agent" -o "' & $TempFile & '"') MsgBox(0,"Code to get Mac Addresses out of S3 DB and into a tempfile","" & $GetMacs) _RunDos($GetMacs) EndFunc -
I have a basic GUI which is ready to receive some input from the end user. One of the controls (control 14) is a checkbox which by default is unticked. The script waits for the user to do the input and press the go button using a While statement, during this time I want it to monitor the state of the checkbox and if it becomes ticked I want to grey out one of the other controls (control 11 - an input box). I can kind of do this, but they way I've done it makes control 11 in the GUI flicker loads because I've put an If statement near the top of my While which checks whether the checkbox (control 14) has been ticked or not and applies a state to the input box (control 11) based on that. The way I'm doing it is a bit rubbish I guess, the state of the checkbox applies an update to the control every time the While statement loops. I want it to update the input box only when a change to the value of the checkbox is applied. Can anyone help? I tried messing around by setting a variable at the start and end of the While statement then comparing them but I couldn't get it to work. Thanks in advance... While 1 If GUICtrlRead(14) = 1 then GUICtrlSetState(11,128) Else GUICtrlSetState(11,64) EndIf $Msg = GUIGetMsg() Select Case $Msg=$CANCEL GUIDelete() Exit Case $Msg=$GUI_EVENT_CLOSE GUIDelete() Exit Case $Msg=$GO ExitLoop EndSelect WEnd
-
Thanks toasterking that looks really clever - I have to admit I don't really understand it all that well, If I'm correct could I use it just by modifying the first line after the comments to point at the application I need to run and giving it the path details etc? Could I use it where the path of the program needs several switches specifying? eg C:\Program files\somefilepath\myapplication.exe /SERVER=myserver /USER=myusername /PASSWORD=mypassword /FILE=filetoprocess I'd pull the command together into a single variable first.
-
Thanks SadBunny & Bert. I'll be able to manage this now - that's great, cheers.
-
Thanks - that's helpful, I'm not able to try it right now, but I just had a quick read up on StdOutRead and I guess it would be something like this? $PiD = _RunDos($Command) $Output = StdOutRead=($PiD) ConsoleWriteError($Output)
-
Hiya, I'm trying to use _RunDos in an AutoIt script and the command is definately running, but I can't tell the result nicely. I'd really like to be able to output the result to the StdErr (or to a file which I can print to the StdErr) The code I'm having a problem with is just one line that looks like this: _RunDos($Command) I'm not sure how to modify it to output the details of what happened as a result of the command to the StdErr If anyone could help I'd really appreciate it. Thanks
-
Read specific part of a text file:
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks for all the help guys.... Ended up with this: Totally different but it worked (extracts the entire line of text with the right software on and then edits the string until I only have what is needed). $Line = 1 $Found = 1 $Success = 1 Do $Data = FileReadLine(@ScriptDir & "\PCNAME.txt",$Line) IF StringInStr($Data," SOLUS 3 Agent ") = 0 Then $Line = $Line + 1 Else $Success = 2 EndIf Until $Success = 2 $Data = StringReplace($Data,"PCNAME","",1) $Data = StringReplace($Data," Capita Business Services Ltd ","",1) $Data = StringReplace($Data,"{","",1) $Data = StringReplace($Data,"}","",1) $Data = StringStripWS($Data,8) $GUID = StringTrimRight($Data,28) MsgBox(0,"GUID Extracted","SOLUS 3 GUID IS - " & $GUID) -
Read specific part of a text file:
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Sorry for the slow reply. The intention is to use AutoIt to find out the GUID (for the Software entry named SOLUS 3 Agent). Once I have the GUID I can then automate an uninstall of that software via msiexec I'll always have the computer name and the software name, but the GUID will always be different. PCNAME {24531475-94B9-4A91-B4AA-16158C6AE026} SOLUS 3 Agent 3.4.118.0 Capita Business Services Ltd 20120704 -
Read specific part of a text file:
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Not for me it isn't!! I get what you're doing and the StringRegExp seems sensible. It just seems to @error when trying to apply the StringRegExp command, so I get the second message box. I've tried stripping out some of the other variables, but I'm not getting anywhere. Thanks anyway - you've given me some more ideas. -
Read specific part of a text file:
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks for the ideas. Didn't realise _StringBetween returns an Array. Looks like the text file didn't upload properly so I'll try again now. Searching between the fancy brackets doesn't work as there are too many entries like that in the file: Here's some more of the text file to help (in case I can't attach it again). PCNAME {0B34DB03-1DA3-4C31-B86C-B2CD9692876F} Foundation Stage Profile 3.3.0 FSP\Version3 20111003 PCNAME {0EFDF2F9-836D-4EB7-A32D-038BD3F1FB2A} Security Update for CAPICOM (KB931906) 2.1.0.2 Microsoft Corporation 20110405 PCNAME {0FFC8EC3-38F4-4A3B-9D2D-6A56DDF4C97C} BDE 5.11 for SIMS Workstation Setup PCNAME {199B7F78-69B7-47C5-8D4B-A3ED1391FB6B} Microsoft Firewall Client 4.0.3442 Microsoft Corporation 20110401 PCNAME {24531475-94B9-4A91-B4AA-16158C6AE026} SOLUS 3 Agent 3.4.118.0 Capita Business Services Ltd 20120704 PCNAME {28b931ed-c100-474c-8c84-85f403a26a85}.sdb Valid Viewer Redirect Patch PCNAME {350C97B0-3D7C-4EE8-BAA9-00BCB3D54227} WebFldrs XP 9.50.7523 Microsoft Corporation 20100906 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6} Microsoft .NET Framework 4 Client Profile 4.0.30319 Microsoft Corporation 20130225 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2160841 {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2160841 KB2160841 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2162169 {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2162169 KB2162169 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2446708 {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2446708 KB2446708 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2446708v2 {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2446708v2 KB2446708v2 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2468871 {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2468871 KB2468871 PCNAME {3C3901C5-3455-3E0A-A214-0B093A5070A6}.KB2473228 Update for Microsoft .NET Framework 4 Client Profile (KB2473228)PCNAME.txt -
I need to read a very specific part of a text file and I'm struggling: My text file lists software (and GUIDs for software) that a particular PC has installed. A single line of the text file reads like this and typically there may be up to 500 lines per file. PCNAME {24531475-94B9-4A91-B4AA-16158C6AE026} SOFTWARE NAME VER.NUM.OF.SW SOFTWARE SUPPLIER DATE I know the name of the piece of software and I can find that inside the text file no problem, but I need to get the GUID out. Here's what I've tried.... This didn't work, I tried using _StringBetween and stating the PCName and the Software to return the GUID but it didn't work. #Include<File.au3> #Include <String.au3> $Hostname = ("PCNAME") $File = ("C:\Remote Uninstall\PCNAME.txt") $FileData = FileRead($File) $GUID = _StringBetween($FileData,$Hostname,"SOFTWARE NAME") MsgBox(0,"GUID",$GUID) I also tried $Hostname = ("PCNAME") $File = ("C:\Remote Uninstall\PCNAME.txt") $FileData = FileRead($File) $Position = StringInStr($FileData,"SOFTWARE NAME") MsgBox(0,"SOFTWARE NAME","String SOFTWARE NAME occurs at position - " & $Position) $StartPos = $Position - 39 ;take away 39 characters from the position found to move to the start of the GUID FileOpen($File,2) FileSetPos($File,$StartPos,0) ;set position in the file FileRead($File,38) ;tried reading 38 characters from the start position. I feel String Regular Expression is probably what I need but I can't see how I'd use it? Any ideas welcome, I've attached a sample text file.
-
I have the same problem - it also takes exactly 15 seconds. I'm using it inside a LAN. If a host is online, then the result is returned almost instantly. If it is not then the ping command takes 15 seconds to finish and let autoit move to the next line to the if statement telling it what msgbox to display. This is regardless of the timeout I set (you'll notice it's set to 1). $Ping = Ping($Hostname,1) If $Ping Then MsgBox(0,"Ping request to " & $Hostname,"A ping request was sent to... " & $Hostname & " ...network connectivity was established.") Call("Func2") Else Msgbox(0,"Status","An error occured connecting to " & $Hostname & ". Check network connectivity and firewall ...will now quit.") Exit EndIf
-
Compare with todays date
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks kylomas - this is the sort of thing I was looking for. Sorry for the slow reply... -
Compare with todays date
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks - I was going to split the dates up but this seems more sensible. -
Compare with todays date
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
I meant more the sort of conditions I'll be checking than how to structure them. -
Compare with todays date
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks for that - I've never used "FileGetTime" before. It's the If statement(s) I don't know where to start with. -
Compare with todays date
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Using _RunDos to run the dir command with switches on it to order the results entries by date _RunDos('dir /O-D "C:MyDirectory" > dir.txt') Then I get the date using filereadline and stringleft as follows: $String = FileReadLine(@ScriptDir & 'dir.txt',6) $LatestDate = StringLeft($String,10) Todays date I was getting in the same format (DD/MM/YYYY) as follows; $TodaysDate = (@MDAY & "/" & @MON & "/" & @YEAR) -
Hi, I expect this question has been asked a million times - so I apologise for this... I've searched but can't find what I'm looking for and I'm drawing a bit of a blank on where to start with it. I have a directory which automatically receives update files every now and then. I want to take the date of the newest file in that directory (DONE) then compare it to today's date. (Format DD/MM/YYYY) Using "If then Else" type logic I'll then work out whether the latest file is less than a week old and if it is then carry out some actions. Any ideas? I haven't got any code to post as I really don't know how to proceed. Thanks.
-
Smtp Mailer That Supports Html And Attachments.
SuperFletch replied to Jos's topic in AutoIt Example Scripts
Thank you. -
Smtp Mailer That Supports Html And Attachments.
SuperFletch replied to Jos's topic in AutoIt Example Scripts
I think I've answered this now, but correct me if I'm wrong. Seeing this UDF makes sure I authenticate with username and password I have been able to log in to an upstream smtp server without needing helo. I'm guessing this is how it is meant to work?? If I'm wrong please tell me as I'd love to know. Anyhow - I've now got a working script now that sends mail (effectively) via my local smtp server without helo. Once again - great UDF -
Smtp Mailer That Supports Html And Attachments.
SuperFletch replied to Jos's topic in AutoIt Example Scripts
Is there a reason I can't find an helo in this UDF? How would I include one? I can get it to work through gmail but not a local smtp provider that seems to require helo. Awesome UDF by the way. TIA, -
SMTP - no message body
SuperFletch replied to SuperFletch's topic in AutoIt General Help and Support
Thanks for quick reply, I now have it working based on an array for the message body. -
I strongly suspect this has been raised before but when you search on smtp you get so many results. I have the following problem, I can send mail but the message body doesn't come through. I've posted my code. Is it because _INetSmtpMail is expecting an array for the body value?? #include <INet.au3> $SmtpServer = "mx.smtp.abc.xyz" $FromName = "My Mailbox" $FromAddress = "myaddress@smtp.abc.xyz" $ToAddress = "youraddress@smtp.abc.xyz" $Subject = "My Test email" $Body = "MESSAGE BODY." $helo = "domain_name" $Mail = _INetSmtpMail ($SmtpServer,$FromName,$FromAddress,$ToAddress,$Subject,$Body,$helo) $err = @error If $Mail = 1 Then MsgBox(0, "Mail Sent", "Mail sent successfully.") Else MsgBox(0, "Error!", "Mail failed with error code." & $err) EndIf
-
Thanks very much for your quick reply - I'll have a look at getting this in place tomorrow. I'll probably try and do it using the array. I didn't know about using the to command either which will help I had been trying something similar using < and >. Thanks immensely.