
Graywalker
Active Members-
Posts
104 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by Graywalker
-
[Useful Information] Privilege Escalation
Graywalker replied to DeltaRocked's topic in AutoIt General Help and Support
I had a tough time when my company converted to Windoze 7 because of this issue. Using psexec is an option if you want to run the program immediatly, but I really didn't want to be that limited and I didn't want to use an external app. Also, the Windows 7 "Do you want to run this" popup is hard to avoid. So, I wrote and have thoroughly tested a script that runs programs with elevated rights on remote Windows 7 computers without a popup - and I just wedged a time adjustment in there yesterday. It uses schtasks. schtasks is a lot more complicated and a bit more mis-documented than AT, but its also more flexible and powerful - and more appropriate for Windows 7 systems. Here is the function code that I use : Func RunProgram($strPCName, $pcc) Dim $Command, $Results = "", $Line, $et, $TName $copyfile = FileCopy($program, "" & $strPCName & "c$temp" & $progarray[$last], 9) $TName = StringTrimRight($progarray[$last], 4) If $copyfile = 1 Then _GetTime() $runtime = @MON & "/" & @MDAY & "/" & @YEAR & " " & $time ;MsgBox(0, "Run Time", $runtime & @CRLF & $et) $Command = 'schtasks /Create /S ' & $strPCName & ' /RU ' & $UserName & ' /RP ' & $Paswrd & ' /SC ONCE /TN ' & _ $TName & ' /TR "' & $CommandLine & '" /ST ' & $time & ' /RL HIGHEST /F' ; /ST ' & $time & ' /ET ' & $et & ' ;/ET ' & $et & ' ;MsgBox(0,"Command",$Command) ;FileWriteLine($LogFile,$Command) $runAt = Run(@ComSpec & ' /c "' & $Command & '"', "", @SW_HIDE, $STDOUT_CHILD) While 1 $Line = StdoutRead($runAt) If @error Then ExitLoop If $Line <> "" Then $Results = $Results & " " & $Line EndIf WEnd FileWriteLine($LogFile, $strPCName & "," & $time & "," & $Results) Else ;FileWriteLine($LogFile, $strPCName & ",Run Program Results,Error Copying File," & $progarray[$last] & " ,Error:," & $copyfile) If FileExists("" & $strPCName & "c$temp" & $progarray[$last]) Then _GetTime() $runtime = @MON & "/" & @MDAY & "/" & @YEAR & " " & $time ;MsgBox(0, "Run Time Else", $runtime & @CRLF & $et) $Command = 'schtasks /Create /S ' & $strPCName & ' /RU ' & $UserName & ' /RP ' & $Paswrd & ' /SC ONCE /TN ' & _ $TName & ' /TR "' & $CommandLine & '" /ST ' & $time & ' /RL HIGHEST /F' ;/ST ' & $time & ' /ET ' & $et & ' /RI 599940 ;/ET ' & $et & ' ;MsgBox(0,"Command Else",$Command) ;FileWriteLine($LogFile,$Command) $runAt = Run(@ComSpec & ' /c "' & $Command & '"', "", @SW_HIDE, $STDOUT_CHILD) While 1 $Line = StdoutRead($runAt) If @error Then ExitLoop If $Line <> "" Then $Results = $Results & " " & $Line EndIf WEnd FileWriteLine($LogFile, $strPCName & "," & $time & "," & $Results) Else FileWriteLine($LogFile, $strPCName & _ ",Run Program Results,Scheduled task not created. Could not copy or find file on endpoint.") EndIf EndIf EndFunc ;==>RunProgram ; because schtasks is so picky about it's time format... Func _GetTime() If @MIN > 55 Then If StringLen(@HOUR) < 2 Then If @HOUR = "9" Then $Hour = (@HOUR + 1) Else $Hour = "0" & (@HOUR + 1) EndIf Else $Hour = (@HOUR + 1) EndIf If $Hour > 23 Then $Hour = "01" EndIf $time = $Hour & ":02" Else If StringLen(@HOUR) < 2 Then $Hour = "0" & @HOUR Else $Hour = @HOUR EndIf If StringLen((@MIN + 2)) < 2 Then $Minu = "0" & (@MIN + 2) Else $Minu = (@MIN + 2) EndIf If $Hour > 23 Then $Hour = "01" EndIf $time = $Hour & ":" & $Minu EndIf ; Just spliced this in to be able to schedule the task to run at night... or any time... $userTime = InputBox("Run Later?","Run at Time (24hr Format)",$time) $time = $userTime EndFunc ;==>_GetTime $TName is a task name. I pull it from the $CommandLine, which is the program to run. So, if the program is installgame.exe the task name is installgame. I select the program to run using : $program = FileOpenDialog("Select Program to Launch", "c:temp", "Executable Files (*.bat;*.exe;*.msi;*.msp)", 3, "runthis.exe") Select Case @error = 1 MsgBox(0, "Nnnnnnnnttt", "File selection Failed") Exit Case @error = 2 MsgBox(0, "Nnnnnnnnnntttt", "Bad file filter") Exit EndSelect $progarray = StringSplit($program, "") $last = $progarray[0] $launchfile = FileExists($program) If $launchfile = 0 Then MsgBox(0, "File not found", "The program to launch was not found, please check location and try again.") Exit ;Return 0 EndIf ; Check for any arguements the program needs $args = InputBox("Arguements", "Any arguements the program needs to run?", "None") Select Case StringInStr($progarray[$last], ".msi") If $args = "None" Then Global $CommandLine = "MsiExec.exe /I c:temp" & $progarray[$last] Else Global $CommandLine = "MsiExec.exe /I c:temp" & $progarray[$last] & " " & $args EndIf Case StringInStr($progarray[$last], ".msp") If $args = "None" Then Global $CommandLine = "MsiExec.exe /P c:temp" & $progarray[$last] & " REINSTALL=ALL REINSTALLMODE=amus" Else Global $CommandLine = "MsiExec.exe /P c:temp" & $progarray[$last] & " " & $args & " REINSTALL=ALL REINSTALLMODE=amus" EndIf Case Else If $args = "None" Then Global $CommandLine = "c:temp" & $progarray[$last] Else Global $CommandLine = "c:temp" & $progarray[$last] & " " & $args EndIf EndSelect I always copy the file to the endpoint, because it is always best to run a program, especially installs, from the local machine. Also, I usually run scripts I've written that put a log file in their folder, so its always easier to check the log file on the endpoint - in the temp directory. I just used this to schedule updates for Acrobat Standard from the install 9.0 up to patch level 9.4.6 on 10 desktops across three states. ( They all ran and Acrobat is updated this morning, even on the 7 windows 7 machines, so it works. Might not be pretty, but it works. ) Oh, yes, using your user name and password is necessary. Whatever account you use must be an administrator on the computer. AT just used the account you were logged on under as your account, but schtasks doesn't seem to do that. And you have to be sure that the secondary logon service is running on the remote computer before schtasks will work properly. Increased security almost always means decreased functionality and a harder time for Systems Administrators. -
StringRegExpReplace Help!!??
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Quite possibly. The whole script is finding the index.dat file in Temporary Internet Files and trying to pull the info from there. I have it working fairly well, but I know its getting a LOT of info, but not pulling all the urls from the file and it is giving me some blank entries - even though I have If StringInStr($ln, "://") And StringLen($ln) > 6 Then before returning the entry. So, the entry has "://" and is longer than six characters, but its displaying in msgbox and reports (csv) as blank?? I haven't even tried for getting the time stamps... It is eventually going to be a function in another script, but if anyone wants to play with index.dat and getting info from it, here is what I've got so far. ; Some sample remote IE History locations ; ;ThatComputerc$UsersSomeUserAppDataLocalMicrosoftWindowsTemporary Internet FilesContent.IE5index.dat ;TheOtherPuterc$Documents and SettingsSomeUserLocal SettingsTemporary Internet FilesContent.IE5index.dat ; ;Registry keys of use ; ;HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorerShell Folders - gives all user folders ;HKEY_USERS.DEFAULTSoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders - gives the paths for user folders #include <Array.au3> $strComputer = @ComputerName $user = @UserName ; the User Name for the folder may have the domain attached to it in some rare cases, ie "UserName.mybiz" Global $logfile = FileOpen("Report.csv", 2) $rprefix = "" & $strComputer & "" $ProfilesPath = RegRead($rprefix & "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorerShell Folders", "Common Documents") ; This gives something like C:UsersPublicDocuments or C:Documents and SettingsAll UsersDocuments - we just want the first part. ; So, find the second "" and remove everything after that $2slash = StringInStr($ProfilesPath, "", 0, 2) $len = StringLen($ProfilesPath) $ProfilesPath = StringTrimRight($ProfilesPath, $len - $2slash) $ProfilesPath = StringReplace($ProfilesPath, ":", "$") ; get the IE history folder path $historypath = RegRead($rprefix & "HKEY_USERS.DEFAULTSoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders", "Cache") ; This gives us something like %USERPROFILE%AppDataLocalMicrosoftWindowsTemporary Internet Files or ; %USERPROFILE%Local SettingsTemporary Internet Files ; Strip out the %USERPROFILE% and we're in business! $historypath = StringReplace($historypath, "%USERPROFILE%", "") $indexdatpath = $rprefix & $ProfilesPath & $user & $historypath & "content.ie5index.dat" $test = FileExists($indexdatpath) ;MsgBox(0,"Index.dat Path",$indexdatpath & @CRLF & $test) _ParseIndexdat($indexdatpath) ;_OBOD_ParseIndexdat($indexdatpath) FileClose($logfile) Exit Func _ParseIndexdat($indexdatpath) ; Parse index.dat file for useable info ; The tools I've seen don't grab all the info I want :( $Bindexdat = FileOpen($indexdatpath, 16) $indexdat = FileRead($Bindexdat);$indexdatpath) $strIndexdat = BinaryToString($indexdat, 1) $strIndexdat = StringReplace($strIndexdat, @CRLF, @CR) $strIndexdat = StringReplace($strIndexdat, @LF, @CR) ;$strIndexdat = StringRegExpReplace($strIndexdat,"f|t|e","") ;$strIndexdat = StringReplace($strIndexdat,Chr(0)," ") $FileArray = StringSplit($strIndexdat, "URL", 1) ;This may get complex... Dim $r = 1 ; to count the records Dim $e = 0; to count the entries Dim $urls, $record = "", $ln Dim $ResultArray[2][5], $i ; Start reading from line 1 $i = 1 For $line In $FileArray ; Get the URLs $linearray = StringSplit($line, @CR, 1) For $ln In $linearray ;$ln = StringRegExpReplace($ln, '[^w/.?:-]', '') ;Enable this here and NOTHING is returned. ? ;$ln = StringStripWS($ln,7) $urls = StringRegExp($ln, "(http|https|res:|file|ftp)") Select Case $urls = 1 $aurls = StringSplit($ln, "REDR", 1) If $aurls[0] > 1 Then For $url In $aurls $url = StringRegExpReplace($url, '[^w/.?:-]', '');"[^[:word:][:blank:]/.?:-]f", "") $url = StringRegExpReplace($url, "(http|https|res:|file|ftp)", "-Start-" & "$1") $httppos = StringInStr($url, "-start-", 0) $url = StringTrimLeft($url, $httppos + 6) If StringInStr($url, "?") Then $ques = StringInStr($url, "?") $len = StringLen($url) $url = StringTrimRight($url, $len - $ques + 1) EndIf If StringInStr($url, "://") And StringLen($url) > 6 Then $url = StringRegExpReplace($url, "(.)(jpg|gif|asp|htm|html|aspx|js|java|php|xhtml|xml|png)", "$1$2" & "-cut-") $cut = StringInStr($url, "-cut-", 1) $len = StringLen($url) $url = StringTrimRight($url, $len - $cut + 1) $ResultArray[$i][1] = $ResultArray[$i][1] & $url & "," EndIf Next Else $ln = StringRegExpReplace($ln, '[^w/.?:-]', '');"[^[:word:][:blank:]/.?:-]f", "") $ln = StringRegExpReplace($ln, "(http|https|res:|file|ftp)", "-Start-" & "$1") If StringInStr($ln, "-Start-") Then $httppos = StringInStr($ln, "-Start-", 0) $ln = StringTrimLeft($ln, $httppos + 6) Else $httppos = StringInStr($ln, "http", 0) $ln = StringTrimLeft($ln, $httppos - 1) EndIf If StringInStr($ln, "?") Then $ques = StringInStr($ln, "?") $len = StringLen($ln) $url = StringTrimRight($ln, $len - $ques + 1) EndIf If StringInStr($ln, "://") And StringLen($ln) > 6 Then $ln = StringRegExpReplace($ln, "(.)(jpg|gif|asp|htm|html|aspx|js|java|php|xhtml|xml|png)", "$1$2" & "-cut-") $cut = StringInStr($ln, "-cut-", 1) $len = StringLen($ln) $ln = StringTrimRight($ln, $len - $cut + 1) $ResultArray[$i][1] = $ResultArray[$i][1] & $ln & "," EndIf EndIf Case StringInStr($ln, "Content-Type:") ; this is an entry I want $ln = StringStripWS($ln, 7) $ResultArray[$i][2] = $ln Case StringInStr($ln, "X-Powered-By:") ; this is an entry I want $ln = StringStripWS($ln, 7) $ResultArray[$i][3] = $ln Case StringInStr($ln, "~U:") ; this is an entry I want and it marks the end of a record $ln = StringReplace($ln, "~U:", "") $ln = StringStripWS($ln, 7) $ResultArray[$i][4] = $ln FileWriteLine($logfile, $ResultArray[$i][1] & "," & $ResultArray[$i][2] & "," & _ $ResultArray[$i][3] & "," & $ResultArray[$i][4]) $i = $i + 1 ReDim $ResultArray[$i + 1][5] ;_ArrayDisplay($ResultArray) Case Else ; do nothing with the line EndSelect Next Next EndFunc ;==>_ParseIndexdat -
StringRegExpReplace Help!!??
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Thank you! That is working better than : $url = StringRegExpReplace($url,"[^[:word:][:blank:]/.?:-]f", "") -
StringRegExpReplace Help!!??
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Some of the lines I am trying to pull urls and text-only from cause problems when posting, but I will try... Line would look like : "®•mÁÖÌÅ`h”3@¼}3@¼}ï¾Þres://ieframe.dll/background_gradient.jpgÞbackground_gradient[2]Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾ÞREDR€ˆ€T2http://servername/Sumtotal/lang-en/management/registrationex/LMS_Registration_Post.aspae9ddabdÞï¾Þï¾" I want to pull "res://ieframe.dll/background_gradient.jpg" and "http://servername/Sumtotal/lang-en/management/registrationex/LMS_Registration_Post.asp" out of that line. To trim the "_Post.aspae9ddabd" down to just "_Post.asp" , I was hoping for something like : $url = StringRegExpReplace($url, "/w*.[:alpha:]{0,4}", "$1-cut-") $cut = stringinstr($url,"-cut-",1) $len = stringlen($url) $url = stringtrimright($url,$len-$cut) Not that it is working as I would expect from reading the "help" file, but also, I could see having to put something to match .asp or .aspx or .html or .htm or .js or on and on... EDIT: $url = StringRegExpReplace($string, "(.)(jpg|gif|asp|htm|html|aspx|js|java|php|xhtml|xml|png)", "$1$2" & "-cut-") Seems to be working fine for doing that. -
I am needing to remove everything that is not a letter, number, non-breaking space or / or . or ? or : or - I am trying this, $result = StringRegExpReplace($string, "[^[:word:][:blank:]/.?:-]", "") But not working. I am still getting all kinds of stuff like "@÷XÉ€ @·RÒð»3”%€ð‘ŽF" left in the string. ?? I could also use some assistance or pointers on replacing "/something.ext" with "/something.ext-cut-" so that I can trim after the extension in a url.
-
Read Binary index.dat file
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Okay, I've found out that the data IS there. I've just got to find a way to get TO it. Func _ParseIndexdat($indexdatpath) ; Parse index.dat file for useable info ; The tools I've seen don't grab all the info I want :( $Bindexdat = FileOpen($indexdatpath, 16) $indexdat = FileRead($Bindexdat);$indexdatpath) ;MsgBox(0, "Index dat", $indexdat) $strIndexdat = BinaryToString($indexdat, 1) $strIndexdat = StringStripWS($strIndexdat, 7) ;MsgBox(0, "String from Binary", $strIndexdat);$strIndexdat & @CRLF & @error) $FileArray = StringSplit($strIndexdat, @CRLF) ;This may get complex... Dim $r = 1 ; to count the records Dim $e = 0; to count the entries ; Start reading from line 1 For $line In $FileArray $line = StringReplace($line, @CRLF, "") $line = StringReplace($line, @CR, "") $line = StringReplace($line, @LF, "") Select Case StringInStr($line, "http://") ; this is the line with a couple entries ;MsgBox(0, "http", $line) ; Check to see if URL is in the line If StringInStr($line, "URL") Then ; it is a REDR or LEAK, trim to URL $urlpos = StringInStr($line, "URL") $line = StringTrimLeft($line, $urlpos) EndIf $httppos = StringInStr($line, "http") $line = StringTrimLeft($line, $httppos - 1) $dotpos = StringInStr($line, ".", "", 3) If $dotpos > 10 Then $content = $line $linelen = StringLen($line) $trimfromright = $linelen - ($dotpos + 3) $line = StringTrimRight($line, $trimfromright) ;MsgBox(0,"Trim", "string lenght : " & $linelen & @CRLF & "dot position: " & $dotpos & @CRLF & "Trim from Right : " & _ ;$trimfromright & @CRLF & $line) Else ; nothing EndIf $record = $line & "," Case StringInStr($line, "Content-Type:") ; this is an entry I want $line = StringStripWS($line, 7) $record = $record & $line & "," Case StringInStr($line, "X-Powered-By:") ; this is an entry I want $line = StringStripWS($line, 7) $record = $record & $line & "," Case StringInStr($line, "~U:") ; this is an entry I want and it marks the end of a record $line = StringReplace($line, "~U:", "") $line = StringStripWS($line, 7) $record = $record & $line FileWriteLine($logfile, $record) $record = "" Case Else ; do nothing with the line EndSelect Next EndFunc ;==>_ParseIndexdat I am getting fairly spotty results - leaving in lots of random characters before and after the URLs. Could anyone come up with a way to use StringRegExp to pull the URLs - all of them - from a line? I've tried several from : http://regexlib.com/Search.aspx?k=URL&AspxAutoDetectCookieSupport=1 with no consistent luck.- 3 replies
-
- Internet Explorer
- History
-
(and 1 more)
Tagged with:
-
Read Binary index.dat file
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
I altered the vbscript to point directly to the index.dat file and it gets info, but returns all kinds of gibberish. ... that totally messes up the reply even when pasted as code! So, I've attached it as a screen cap.- 3 replies
-
- Internet Explorer
- History
-
(and 1 more)
Tagged with:
-
Read Binary index.dat file
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Looks like Vengy forgot to include a function in his IE_Network script. It can be found here : http://www.motobit.com/tips/detpg_binarytostring/- 3 replies
-
- Internet Explorer
- History
-
(and 1 more)
Tagged with:
-
The goal here is to get the Internet History for endpoints and users in the enterprise to find what business use websites use Java. When opening index.dat in Notepad, I can see all the data I need. Unfortunatly, trying to read that data in AutoIT is proving diffucult. I've tried : Func _ParseIndexdat($indexdatpath) ; Parse index.dat file for useable info ; The tools I've seen don't grab all the info I want :( $Bindexdat = FileOpen($indexdatpath,16) $indexdat = FileRead($Bindexdat) $strIndexdat = BinaryToString($indexdat,2) MsgBox(0,"String from Binary",$strIndexdat) $FileArray = StringSplit($strIndexdat,@CRLF) ;This may get complex... Dim $r = 1 ; to count the records Dim $e = 0; to count the entries ; Start reading from line 1 For $line In $FileArray $content = StringStripWS($line,7) Select Case StringInStr($line,"REDR") ; this is the start of a record MsgBox(0,"REDR",$content) Case StringInStr($line,"URL") ; this may be the start of a record MsgBox(0,"URL",$content) Case StringInStr($line,"LEAK") ; this is the start of an error record ; I will likely ignore it. MsgBox(0,"LEAK",$content) Case StringInStr($line,"http://") ; this is the line with a couple entries MsgBox(0,"http",$content) Case StringInStr($line,"Content-Type:") ; this is an entry I want MsgBox(0,"Content-Type",$content) Case StringInStr($line,"X-Powered-By:") ; this is an entry I want MsgBox(0,"Powered-By",$content) Case StringInStr($line,"~U:") ; this is an entry I want and it marks the end of a record MsgBox(0,"~U",$content) Case Else ; do nothing with the line EndSelect Next EndFunc That doesn't get the info... That code doesn't return anything. Using $Bindexdat = FileOpen($indexdatpath,16) $indexdat = FileRead($Bindexdat) $strIndexdat = BinaryToString($indexdat,1) MsgBox(0,"String from Binary",$strIndexdat) the "string from binary" msg box shows a LOT of data... but URL and http case are both blank or gibberish. BinaryToString($indexdat,2) and ,3 return Nothing in the cases - 4 does the same as 1. Using : $Bindexdat = FileOpen($indexdatpath, 16) $indexdat = FileRead($Bindexdat);$indexdatpath) MsgBox(0,"Index dat",$indexdat) $strIndexdat = BinaryToString($indexdat,1) MsgBox(0,"String from Binary",$indexdat);$strIndexdat & @CRLF & @error) $FileArray = StringSplit($strIndexdat,@CRLF) Shows that $indexdat and $strIndexdat are effectively the same. Using : ; Parse index.dat file for useable info ; The tools I've seen don't grab all the info I want :( ;$Bindexdat = FileOpen($indexdatpath,16) $indexdat = FileRead($indexdatpath);$Bindexdat) ;$strIndexdat = BinaryToString($indexdat,4) MsgBox(0,"String from Binary",$indexdat);$strIndexdat & @CRLF & @error) $FileArray = StringSplit($indexdat,@CRLF) It reads a lot more info... Content-Type is fine. ~U: is fine. URL is mostly blank. Case http:// it will pop up the msg box, but $content is blank. So the data is there... I just can't figure out how to get it into a string. Using : $Bindexdat = FileOpen($indexdatpath,256) $indexdat = FileRead($Bindexdat);$indexdatpath) MsgBox(0,"Index dat",$indexdat) $strIndexdat = BinaryToString($indexdat,1) MsgBox(0,"String from Binary",$indexdat);$strIndexdat & @CRLF & @error) $FileArray = StringSplit($strIndexdat,@CRLF) Returns data, but URL and Http:// pop up as blank... $Bindexdat = FileOpen($indexdatpath,48) - URL and Http are blank. I've found a VBScript that is supposed to read the files... so far no luck on Win7 - it can't find index.dat file... lol! On remote XP machines, it can't find a history folder. So I don't know if it DOES read index.dat files. I've attached it. Any ideas or code help is greatly appreciated!! IE_Network - Copy.txt
- 3 replies
-
- Internet Explorer
- History
-
(and 1 more)
Tagged with:
-
Nothing? Really? Okay, how about a way to get the IE History remotely using AutoIT? Maybe the last 10 URLs visited? I hope that would include the currently open windows.... The script I wrote is not going to work, because of the way the User environments work... I can get the running processes of a user, but I can't, with an admin account, see the currently open windows on the user's account using _IEwhatever UDF or the WinList function. (running script using scheduled task as admin) So... how to get the URLs???
-
Got the URLs of the Tabs! The following code seems to be mostly working - on a local machine. It doesn't work with Firefox, but that is not absolutely necessary at this point, although I would LOVE it if someone provided a solution to that - and doing it from a central computer to other computers on the local network. The code lists all windows with "Internet Explorer" in the title bar, then tries to get an object from each - if it is not an object on it's own, it tries to see if it is embedded in the previous object. Either way, it tries to get the Title and the URL of the window - hopefully Internet Explorer. Unfortunatly, if someone changed the IE window title to "Internut Exploder", then this won't work too well. AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("WinDetectHiddenText", 1) $awins = WinList("Internet Explorer") $mainhwnd = "" For $w = 1 To $awins[0][0] FileWriteLine($logfile, "Windows array " & $w & "," & $awins[$w][0] & "," & $awins[$w][1]) $oBrowser = _IEAttach($awins[$w][1], "HWND") If IsObj($oBrowser) Then $oldmainhwnd = $mainhwnd $mainhwnd = $awins[$w][1] $bURL = _IEPropertyGet($oBrowser, "locationurl");$oBrowser.Document.Location.href $bName = _IEPropertyGet($oBrowser, "title");$oBrowser.Location $Pid = WinGetProcess($awins[$w][1]) FileWriteLine($logfile, $bName & "," & $bURL & "," & $Pid) Else If $oldmainhwnd = $mainhwnd Then ;Do Nothing, same old stuff. Else For $w2 = 1 To $awins[0][0] $oBrowser = _IEAttach($mainhwnd, "Embedded", $w2) If IsObj($oBrowser) Then $bURL = _IEPropertyGet($oBrowser, "locationurl");$oBrowser.Document.Location.href $bName = _IEPropertyGet($oBrowser, "title");$oBrowser.Location $Pid = WinGetProcess($awins[$w][1]) FileWriteLine($logfile, $bName & "," & $bURL & "," & $Pid & ", Using HWND " & $mainhwnd & ", $w2 = " & $w2 & ", old hwnd = " & $oldmainhwnd) Else ; Do nothing - maybe exitloop?? EndIf Next $oldmainhwnd = $mainhwnd EndIf EndIf Next If anyone shows interest, I will post the whole script to look for java and get the URLs that called it when I get that script completed. This piece was a monster all by itself.
-
More info! Getting closer.... The following code gets the PID with the window - because once you have the handle, you can use the handle instead of the window title. However, with tabbed browsing, the WinGetText($handle) only gets the tab that is in focus. Since most of my enterprise is on IE 7, this won't be much of an issue... BUT... it could get that way. Also, _IEAttach seems to have the same issue with tabs. Any ideas how to get the URLs of tabs? If StringInStr($Aprocesses[$i][4], "iexplore") Then $Pid = "" $wtext = "" $url = "" If WinExists("Internet Explorer") Then $awins = WinList("Internet Explorer") ;_ArrayDisplay($awins) For $w = 1 To $awins[0][0] $Pid = WinGetProcess($awins[$w][1]) ;If $Pid = $Aprocesses[$i][1] Then $wtext = WinGetText($awins[$w][1]) $wtexta = StringSplit($wtext, @LF) For $l = 1 To $wtexta[0] If StringInStr($wtexta[$l], "http") Then $url = $wtexta[$l] ExitLoop EndIf Next ;EndIf MsgBox(0,"Array Info",$Pid & @CRLF & $url) Next EndIf
-
Wow... I guess it is complicated... lol! So, I've discovered a few ways to get the URL from the Window based on the window title : AutoItSetOption("WinTitleMatchMode", 2) If WinExists("Internet Explorer") Then $wtext = WinGetText("Internet Explorer") $wtexta = StringSplit($wtext, @LF) For $l = 1 To $wtexta[0] If StringInStr($wtexta[$l], "http") Then $url = $wtexta[$l] ExitLoop EndIf Next EndIf MsgBox(0, "URL", $url) Endif OR AutoItSetOption("WinTitleMatchMode", 2) #include <IE.au3> $awins = WinList("Internet Explorer") For $w = 1 to $awins[0][0] $oBrowser = _IEAttach($awins[$w][1],"HWND") If IsObj($oBrowser) Then $bURL = $oBrowser.LocationURL $bName = $oBrowser.LocationName MsgBox(0,"Browser Info",$bName & @CRLF & $bURL) EndIf Next But neither lets me a) Get it remotely Tie it directly to the Process ID - and both rely on the Window Title having "Internet Explorer" in it. (edit to clarify - that means that if there are multiple windows of Internet Explorer open, I can't be sure which URL is the one that opened Java.) Not happy.... any ideas? ... and why THIS doesn't work, I don't know!! $oBrowser = _IEAttach($objProcess.Handle, "HWND") If IsObj($oBrowser) Then $bURL = $oBrowser.LocationURL $bName = $oBrowser.LocationName MsgBox(0, "Browser Info", $bName & @CRLF & $bURL) Else MsgBox(0, "NOT an Object!", "Dummy!!") EndIf ... actually, I suppose I do... I think the "Handle" returned by Win32_Process is actually the Process ID, not a "HWND" handle.
-
MsgBox(0,"Internet Explorer", "You browsing the URL " & $Window.LocationURL) works just as well as MsgBox(0,"Internet Explorer", "You browsing the URL " & $Window.Document.Location.href) Something odd - I am on Windows 7 64bit - I have an open IE window. $oIE = ObjGet("","InternetExplorer.Application") $url = $oIE.LocationURL $name = $oIE.LocationName Returns an error on $url = $oIE.LocationURL of "==> Variable must be of type "Object".:"
-
Task : If Java.exe opens and it's parent process is a browser, get the URL of the web page it has open (hopefully the URL that started java). I would love a way to do it remotely, but can live with having to run a monitor on the local machine. What I have now is a function that uses WMI to query win32_process and get the processes and parent process id, searches that for Java and puts that info into a report. I want to include the URL of the webpage that launched java. What I have so far is below, but it doesn't let me tie the Process ID to the window I get the URL from. It also will not get Firefox windows. The Shell method only gets Shell windows. I have nine windows open, but it only picks up two - internet explorer and file system explorer - missing both Firefox windows and all their tabs. So, the question is - how to get a browser object when I start with only a Process ID and get the URL from that object? On a remote computer? $oShell = ObjCreate("shell.application") ; Get the windows shell object $oShellWindows = $oshell.windows ; Get open windows If IsObj($oShellWindows) Then $string = "" For $Window in $oShellWindows ; count all windows $Wpid = ObjName($Window,3) $string = $string & $Window.LocationName & " ; " & $Window.FullName & " ; " & $Wpid & @CRLF If StringInStr($Window.FullName, "iexplore") Then MsgBox(0,"Internet Explorer", "You browsing the URL " & $Window.Document.Location.href) EndIf Next MsgBox(0,"Shell Windows", "You have the following " & $oShellWindows.Count & " windows open:" & @CRLF & $string); EndIf Fantasy code I would like to work: $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strPCName & "\root\cimv2") If IsObj($objWMIService) Then $colProcesses = $objWMIService.ExecQuery( _ "select * from win32_process") For $objProcess In $colProcesses If $objProcess.ProcessId = $javaparentPID Then $Name = $objProcess.LocationName $URL = $objProcess.Document.Location.href Endif Code that gets the process IDs : Func _ProcessInfo($strPCName) Dim $i = 0 Dim $User, $Domain, $objWMIService, $colProcesses, $procnum Dim $Aprocesses[1][9] Dim $pi, $ppi, $parent, $parentfound $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strPCName & "\root\cimv2") ; Gather process information into an array If IsObj($objWMIService) Then $colProcesses = $objWMIService.ExecQuery( _ "select * from win32_process") For $objProcess In $colProcesses $i = $i + 1 ReDim $Aprocesses[$i + 1][9] $Aprocesses[$i][1] = $objProcess.ProcessId $Aprocesses[$i][2] = $objProcess.Caption $Aprocesses[$i][3] = $objProcess.HandleCount $Aprocesses[$i][4] = $objProcess.ExecutablePath $Aprocesses[$i][5] = $objProcess.ParentProcessId $Aprocesses[$i][6] = $objProcess.CreationDate If $objProcess.GetOwner($User, $Domain) = 0 Then $Aprocesses[$i][7] = $Domain & _ "\" & $User Else $Aprocesses[$i][7] = "" EndIf Next $Aprocesses[0][0] = $i $procnum = $i ;_ArrayDisplay($Aprocesses) ; Process the information about the Processes - LOL! $parentfound = 0 For $pi = 1 To $procnum ; only looking for Java, so : If StringInStr($Aprocesses[$pi][2], "java") Then $parent = $Aprocesses[$pi][5] For $ppi = 1 To $procnum If $Aprocesses[$ppi][1] = $parent Then $parentfound = 1 ExitLoop EndIf Next If $parentfound = 1 Then ; It has a parent process still running! $line = $strPCName & "," & $Aprocesses[$pi][1] & "," & $Aprocesses[$pi][2] & "," & $Aprocesses[$pi][3] & "," & _ $Aprocesses[$pi][4] & "," & $Aprocesses[$pi][5] & "," & $Aprocesses[$pi][6] & "," & _ $Aprocesses[$ppi][6] & "," & $Aprocesses[$ppi][2] & "," & $Aprocesses[$ppi][4] & "," & _ $Aprocesses[$ppi][7] FileWriteLine($LogFile, $line) Else ; parent process left. No, little java, its not your fault... :) $line = $strPCName & "," & $Aprocesses[$pi][1] & "," & $Aprocesses[$pi][2] & "," & $Aprocesses[$pi][3] & "," & $Aprocesses[$pi][4] & "," & _ $Aprocesses[$pi][5] & "," & $Aprocesses[$pi][6] & ",Parent already closed or not found" & ",Owner = ," & $Aprocesses[$pi][7] FileWriteLine($LogFile, $line) EndIf EndIf $parentfound = 0 $ppi = 0 Next Else FileWriteLine($LogFile, $strPCName & ",Unable to query WMI on endpoint") EndIf EndFunc ;==>_ProcessInfo
-
Windows 7 UAC and Systems Administrators
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Without using third-party or non-native utilities, there is not much of anything one can do to get around UAC - even when UAC is disabled there are stills some issues. I have found one sure way using schtasks in Windows 7, but it requires providing a user name and password that is in the Administrators group. Using /U and /P would wait until that user was logged in. Probably need to have Secondary Logon enabled and starting automatically. I copy the program I want to run down to the endpoint first. ; $CommandLine = program to run ; $TName = a name for the task ; $time must be ##:## format. (24hr) 1:03 will give an error. 01:03 is good. ; /SC ONCE rules out using /Z for some reason $Command = 'schtasks /Create /S ' & $strPCName & ' /RU ' & $UserName & ' /RP ' & $Paswrd & ' /SC ONCE /TN ' & $TName & ' /TR "' & $CommandLine & '" /ST ' & $time & ' /RL HIGHEST /F' ;/ST ' & $time & ' /ET ' & $et & ' /RI 599940 $runAt = Run(@ComSpec & ' /c "' & $Command & '"', "", @SW_HIDE, $STDOUT_CHILD) While 1 $Line = StdoutRead($runAt) If @error Then ExitLoop If $Line <> "" Then $Results = $Results & " " & $Line EndIf WEnd FileWriteLine($LogFile, $strPCName & "," & $time & "," & $Results) -
This is a question for Systems Administrators of all kinds - those who manage software on a domain where users have restricted rights - and who have Windows 7 computers in their domain. How do you get around UAC to install Software or Certificates remotely and without user intervention? ... and without being logged in to the computer. ( There is no such thing as "right click and.." answers. We have over 3000 computers! ) I've tried scheduled tasks (schtasks.exe) with the /RL HIGHEST switch - no good. I've even looked into PowerShell 2.0 - but it is not what I need. Even with UAC disabled, some things still need the "Run As Administrator" privileges to actually install properly. Has Microsoft completely screwed Systems Administrators with this UAC ??
-
ControlClick("AutoIt Help", "&Display", "3006") I see the problem... I just fixed mine. You are using the Au3Info.exe - "Autoit3 Window Info" tool. You are using the "controlID" and that is not what it is actually looking for - even though the syntax says : ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] ) Instead of controlID, it really wants the ClassnameNN. In my example, the controlID was 5009, but I had to change it to the following to get it to work : ControlClick("Settings for Server","","Button5","primary")
-
Script Locks Up [reopened]
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Apparently I was wrong and that is not my issue. The script is just randomly hanging at any and all locations. the report from : Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info does not agree with what I am getting from a trace report txt file - the txt file shows the script is way past where the debug tray info shows. I am at a complete loss... no correlation as to effect and cause... hangs on random computers, after random number of systems - from 22 to 1575 - and random lines in the script. My only thought now is that I am using up resources or handles??? I replaced the $locator with : $psscmd = " \\" & $strPCName & " query winmgmt" $WMITest = Run(@ComSpec & " /c sc" & $psscmd, "", @SW_HIDE, $STDOUT_CHILD) $pt = TimerInit() While 1 $line = StdoutRead($WMITest) If @error Then ExitLoop $ptd = TimerDiff($pt) If $ptd > 50000 Then ProcessClose($WMITest) ExitLoop EndIf If $line <> "" Then $wmires = $wmires & $line & @CRLF EndIf WEnd StdioClose($WMITest) $pss_check = StringInStr($wmires, "Running") Just to be sure that it was not causing the hanging... Its just gotten worse. So - question is, does using the Run and $STDOUT_CHILD three times on each computer, with hundreds of computers, max out some resources and hang the script? If so, how to release those after each computer? Or something else causing the hanging? Full code : #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=C:\Users\ME\Pictures\computer_network.ico #AutoIt3Wrapper_outfile=AssetCollect.exe #AutoIt3Wrapper_UseX64=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "String.au3" #include "ADFunctions.au3" #include "ServiceControl.au3" #include "array.au3" #include "Date.au3" #include "Constants.au3" ;OnAutoItExitRegister("ExitReport") ;Opt("TrayAutoPause", 0) ;0=no pause, 1=Pause ;Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info ;Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon FileInstall("psservice.exe", @ScriptDir & "\psservice.exe") FileInstall("sc.exe", @ScriptDir & "\sc.exe") FileInstall("NoBMC.exe", @ScriptDir & "\NoBMC.exe") FileInstall("NoTrend.exe", @ScriptDir & "\NoTrend.exe") ;----- Customize the following constants for your needs ----- Const $statusfilen = "status" & @MON & @MDAY & @YEAR & ".txt" Const $ResultsFile = "AssetCollect" & @MON & @MDAY & @YEAR & ".csv" Const $ScriptVersion = 1.0 Global $g_eventerror = 0 ; to be checked to know if com error occurs. Must be reset after handling. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler Global $psservice = @ComSpec & ' /c "' & @ScriptDir & '\psservice.exe" -accepteula' Global $pslist = @ComSpec & ' /c "' & @ScriptDir & '\pslist.exe" -accepteula' Global $recheck = "" ;------ Constant Declarantions ---------- Const $ForReading = 0 Const $ForWriting = 2 Const $ForAppending = 1 Const $LDAP_Suffix = "DC=WORKPLACE,DC=local" Const $adOpenStatic = 3 Const $adLockOptimistic = 3 Const $adCmdText = "&H0001" Const $ADS_SCOPE_SUBTREE = 2 If Not FileExists("NoBMC.txt") Then Global $nobmcfile = FileOpen("NoBMC.txt", 2) Global $notrendfile = FileOpen("NoTrend.txt", 2) Else Global $nobmcfile = FileOpen("NoBMC2.txt", 2) Global $notrendfile = FileOpen("NoTrend2.txt", 2) EndIf ; Constants for the NameTranslate function. Const $ADS_NAME_INITTYPE_GC = 3 Const $ADS_NAME_TYPE_NT4 = 3 Const $ADS_NAME_TYPE_1779 = 1 ; Dim the Variables used Global $objAD_Recordset, $strDN, $strPCName, $objPC, $RecordCount, $pcc, $objAD_Command, $a_PCNames Dim $i = 0 Global $ErrorFile, $timenow, $start, $statusfile Global $ExistingService, $sTunerService, $TunerPath Global $servicenames[18] ; Set Service Names $servicenames[0] = "BMCservice1" $servicenames[1] = "BMCservice2" $servicenames[2] = "BMCservice3" $servicenames[3] = "BMCservice4" $servicenames[4] = "BMCservice5" $servicenames[5] = "BMCservice6" $servicenames[6] = "BMCservice7" $servicenames[7] = "BMCservice8" $servicenames[8] = "BMCservice9" $servicenames[9] = "BMCservice10" $servicenames[10] = "BMCservice11" $servicenames[11] = "BMCservice12" $servicenames[12] = "BMCserviceLaptop" $servicenames[13] = "BMCserviceSrVR" $servicenames[14] = "BMCservicePkg" $servicenames[15] = "BMCservice_end" $servicenames[16] = "BMCservice_Main" $servicenames[17] = "Test" ; Establish Log File to write results to $LogFile = FileOpen($ResultsFile, $ForWriting) If @error = -1 Then MsgBox(0, "Error", "ERROR: Unable to initialize requested log file, " & $ResultsFile & ".") FileClose($LogFile) Exit EndIf ;Err.Number <> 0 $ErrorFile = FileOpen("ErrorFile" & @MON & @MDAY & @YEAR & ".csv", $ForWriting) If @error = -1 Then MsgBox(0, "Error", "ERROR: Unable to initialize requested Error log file.") FileClose($ErrorFile) Exit EndIf ; Set the Status file If FileExists($statusfilen) Then FileCopy($statusfilen, "OldStatusFile.txt") FileDelete($statusfilen) EndIf $statusfile = FileOpen($statusfilen, $ForWriting) ; Set start time in status file $now = _Now() ;$status = FileOpen($statusfile, $ForWriting) FileWriteLine($statusfile, "Started Collect at : " & $now) ;FileClose($status) ; Prepare Active Directory and Query Global $objConnection = ObjCreate("ADODB.Connection"); Create COM object to AD $objConnection.ConnectionString = "Provider=ADsDSOObject" $objConnection.Open("Active Directory Provider"); Open connection to AD $objAD_Command = ObjCreate("ADODB.Command") $objAD_Command.ActiveConnection = $objConnection $objAD_Command.CommandText = "SELECT * FROM 'LDAP://DC=WORKPLACE,DC=local' WHERE objectClass='computer' AND 'userAccountControl:1.2.840.113556.1.4.803:'<>2" $objAD_Command.Properties("Page Size") = 1000 $objAD_Command.Properties("Searchscope") = 2 $objAD_Recordset = $objAD_Command.Execute $RecordCount = $objAD_Recordset.recordcount ; Set Results File Headers FileWriteLine($LogFile, "Computer Name, Ping?, OS, OS SP, OS Version, Date Changed (GMT), Date Created (GMT), Password Changed, IP Subnet, Tuner File?, Tuner Installed?, Tuner Service?, Trend?, TrendServer, GoverLan?, Free C: MB, StartBMC?") ;$status = FileOpen($statusfile, $ForAppending) FileWriteLine($statusfile, "Working with " & $RecordCount & " computers.") ;FileClose($status) Do ; Set trace file ;$trace = FileOpen(@ScriptDir & "\tracereport.txt", 2) $strDN = $objAD_Recordset.Fields(0).value $objPC = ObjGet($strDN) If IsObj($objPC) Then $strPCName = ($objPC.cn) $pcc = $pcc + 1 ;FileWriteLine($trace, 'Starting ' & $strPCName & " pc " & $pcc & @CRLF & @CRLF) ;### Trace Console InfoCollect($strPCName, $objPC, $pcc) Else FileWriteLine($ErrorFile, "Unable to get Object (line 130) on PC " & $pcc & ", " & $strDN) FileWriteLine($LogFile, $strDN & ",Not an Object") $recheck = $recheck & "!" & $strDN $pcc = $pcc + 1 EndIf $objAD_Recordset.MoveNext() ; Set trace file ;FileClose($trace) Until $objAD_Recordset.EOF() FileClose($nobmcfile) FileClose($notrendfile) ; Kick off BMC Install and Trend Repair Run("NoBMC.exe", @ScriptDir) Run("NoTrend.exe", @ScriptDir) ; re-check unavailable computers ; Set complete time for first run $now = _Now() FileWriteLine($statusfile, "Completed & Started Re-Check at : " & $now) ;FileClose($status) $pcc = 0 ; make sure time is during working hours to capture laptops missed by midnight launch Do $timenow = @HOUR & @MIN If $timenow > "0830" And $timenow < "1400" Then $start = "YES" ExitLoop Else $start = "No" Sleep(1500000) EndIf Until $start = "YES" ; put entry into status file $now = _Now() FileWriteLine($statusfile, "Re-check begins working at : " & $now) If Not FileExists("NoBMC.txt") Then Global $nobmcfile = FileOpen("NoBMC.txt", 2) Global $notrendfile = FileOpen("NoTrend.txt", 2) Else Global $nobmcfile = FileOpen("NoBMC2.txt", 2) Global $notrendfile = FileOpen("NoTrend2.txt", 2) EndIf $a_PCNames = StringSplit($recheck, "!") If Not IsArray($a_PCNames) Then $a_PCNames[0] = 1 $a_PCNames[1] = $recheck EndIf $RecordCount = $a_PCNames[0] $now = _Now() FileWriteLine($statusfile, "Re-checking " & $RecordCount & " computers, starting : " & $now) ;FileClose($status) Do ; Set trace file ;$trace = FileOpen(@ScriptDir & "\tracereport.txt", 2) ;FileWriteLine($trace, 'Recheck Starting ' & $strPCName & " pc " & $pcc & @CRLF & @CRLF) ;### Trace Console $q_eventerror = 0 $pcc = $pcc + 1 $strDN = "LDAP://" & $a_PCNames[$pcc] $objPC = ObjGet($strDN) If IsObj($objPC) Then $strPCName = ($objPC.cn) InfoCollect($strPCName, $objPC, $pcc) Else FileWriteLine($ErrorFile, "Unable to get Object (line 182) on PC " & $pcc & ", " & $strDN) FileWriteLine($LogFile, $strDN & ",Not an Object") EndIf ; close trace file ;FileClose($trace) Until $pcc = $RecordCount ResultsCleanup() ; Set complete time for full run $now = _Now() FileWriteLine($statusfile, "Completed : " & $now) FileClose($statusfile) FileClose($LogFile) FileClose($ErrorFile) FileClose($nobmcfile) FileClose($notrendfile) ; Kick off BMC Install and Trend Repair again If ProcessExists("NoBMC") Then While ProcessExists("NoBMC") Sleep(3000) WEnd Else Run("NoBMC.exe", @ScriptDir) EndIf If ProcessExists("NoTrend") Then While ProcessExists("NoTrend") Sleep(3000) WEnd Else Run("NoTrend.exe", @ScriptDir) EndIf Exit ; ********* Functions that do the actual working ********** Func InfoCollect($strPCName, $objPC, $pcc) Dim $strOS, $strOSsp, $strOSv, $strChange, $strCreate, $sTempFile, $IsAlive Dim $stripIP, $arrIP, $strSubnet, $pingresult, $sStart, $sEnd, $sString, $strADGROUP Dim $cDay, $cHour, $cMin, $cMonth, $cYear, $crDay, $crYear, $crHour, $crMin, $crMonth, $netwrkAddr, $pt, $ptd Dim $strGroup, $Group, $Groups, $s, $sTrendService, $qTrendService, $qTunerService, $lastlogon, $thegroup, $wmires = "" Dim $arrGroups, $fqdn, $memberof, $strTunerPathC, $strTunerPathD, $strTunerPathE, $strPwdCh, $strPwdChd, $exitcode Dim $IPSubkey, $IPkey, $keyread = "No", $r = 0, $drivespace, $Locator, $Service, $TrendServer, $hundreds, $startbmc Dim $ABCDService, $ABCSAService, $ABCRpService, $ABCLaptop, $ApplicationPkgr, $EndNode, $JacksonMain, $Test, $stanum, $ABCDRepeater Dim $ABCDay, $ABCMirror, $ABCATM, $sTunerServicei, $WMITest, $psscmd, $pss_check, $sGoverLan, $qGoverLan, $ABC_Server Dim $services = "\HKLM\SYSTEM\CurrentControlSet\Services" Dim $iSecurityFlags = "&H80" ; "wbemConnectFlagUseMaxWait" or 128 or &H80 Global $trendkey = "\\" & $strPCName & "\HKLM\SOFTWARE\TrendMicro" $qTunerService = 0 $qGoverLan = 0 $qTrendService = 0 $sTunerService = "" $sTrendService = "X" $sGoverLan = "X" $TrendServer = "X" $IsAlive = "X" $strOS = "X" $strOSsp = "X" $strOSv = "X" $strChanged = "X" $strCreated = "X" $strPwdChd = "X" $strSubnet = "X" $TunerPath = "X" $sTunerServicei = "X" $drivespace = "X" $startbmc = "X" $keyread = "X" $stanum = $pcc / 100 If IsInt($stanum) Then $now = _Now() FileWriteLine($statusfile, " " & $pcc & " at : " & $now) FileFlush($LogFile) FileFlush($statusfile) EndIf ;FileWriteLine($trace, "Starting " & $strPCName & " at " & $now) ;;FileFlush($trace) ;MsgBox(0, "PC Name", $strPCName) $fqdn = $objPC.distinguishedName $strOS = $objPC.operatingSystem $strOSsp = $objPC.operatingSystemServicePack $strOSv = $objPC.operatingSystemVersion $strChange = $objPC.whenChanged $strCreate = $objPC.whenCreated $strPwdCh = $objPC.passwordLastChanged ; check for stale workstation or BMC only AD Account If StringInStr($fqdn, "stale") Then $IsAlive = $IsAlive & "STALE " ElseIf StringInStr($fqdn, "BMC CM") Then $IsAlive = $IsAlive & "BMC AD " EndIf ; Convert the whenChanged date to something useable by Excel $cYear = StringLeft($strChange, 4) $cMonth = StringMid($strChange, 5, 2) $cDay = StringMid($strChange, 7, 2) $cHour = StringMid($strChange, 9, 2) $cMin = StringMid($strChange, 11, 2) $strChanged = $cMonth & "/" & $cDay & "/" & $cYear & " " & $cHour & ":" & $cMin ; Convert the whenCreated date to something useable by Excel $crYear = StringLeft($strCreate, 4) $crMonth = StringMid($strCreate, 5, 2) $crDay = StringMid($strCreate, 7, 2) $crHour = StringMid($strCreate, 9, 2) $crMin = StringMid($strCreate, 11, 2) $strCreated = $crMonth & "/" & $crDay & "/" & $crYear & " " & $crHour & ":" & $crMin ; Convert the pwdLastSet to something useable by Excel $crYear = StringLeft($strPwdCh, 4) $crMonth = StringMid($strPwdCh, 5, 2) $crDay = StringMid($strPwdCh, 7, 2) $crHour = StringMid($strPwdCh, 9, 2) $crMin = StringMid($strPwdCh, 11, 2) $strPwdChd = $crMonth & "/" & $crDay & "/" & $crYear & " " & $crHour & ":" & $crMin ; Ping the computer and store results in a temp file Local $pingresult, $ping $ping = "" ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $pingresult = Run" & @CRLF) ;;FileFlush($trace) $pingresult = Run(@ComSpec & " /c " & 'ping -n 2 ' & $strPCName, "", @SW_HIDE, $STDOUT_CHILD) $pt = TimerInit() While 1 $line = StdoutRead($pingresult) If @error Then ExitLoop $ptd = TimerDiff($pt) If $ptd > 50000 Then ProcessClose($pingresult) ExitLoop EndIf ;MsgBox(0,"line",$line) If $line <> "" Then $ping = $ping & $line & @CRLF EndIf WEnd StdioClose($pingresult) ; Check to see if there was a Time to Live on the ping, meaning the pc responded. ;MsgBox(0, "Ping", $ping) $TTL = StringInStr($ping, "TTL=") Select Case $TTL > 0 $IsAlive = "Responding" Case Else $IsAlive = "Not Responding to Ping" EndSelect ;FileWriteLine($trace, " Ping Completed - " & $ptd & " milliseconds, " & $IsAlive) ;;FileFlush($trace) $sString = $ping $sStart = "from " $sEnd = ": " $stripIPa = _StringBetween($sString, $sStart, $sEnd) If IsArray($stripIPa) Then $stripIP = $stripIPa[0] Else $stripIP = @error EndIf ;$Locator = ObjCreate("WbemScripting.SWbemLocator") ;;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $Service = $Locator.ConnectServer" & @CRLF) ;;;FileFlush($trace) ;$Service = $Locator.ConnectServer($strPCName, "root/CIMV2", "", "", "", "", $iSecurityFlags) ; strserver,namespace,user,password,locale,authority,isecurityflags,namedvalueset ;If IsObj($Service) Then If $IsAlive = "Responding" Then ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & ' $psscmd = " \\" & $strPCName & " query winmgmt"' & @CRLF) ;;FileFlush($trace) ; Test to see if the WMI Service is behaving $psscmd = " \\" & $strPCName & " query winmgmt" ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $WMITest = Run(@ComSpec & ' /c sc' & $psscmd, "", @SW_HIDE, $STDOUT_CHILD)" & @CRLF) ;;FileFlush($trace) $WMITest = Run(@ComSpec & " /c sc" & $psscmd, "", @SW_HIDE, $STDOUT_CHILD) ;$pss_check = ProcessWaitClose($WMITest, 32) ;$exitcode = @extended $pt = TimerInit() While 1 $line = StdoutRead($WMITest) If @error Then ExitLoop $ptd = TimerDiff($pt) If $ptd > 50000 Then ProcessClose($WMITest) ExitLoop EndIf ;MsgBox(0,"line",$line) If $line <> "" Then $wmires = $wmires & $line & @CRLF EndIf WEnd StdioClose($WMITest) $pss_check = StringInStr($wmires, "Running") ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + - 2) & " $pss_check : " & $pss_check & " exit code : " & @extended & @CRLF) ;;FileFlush($trace) If $pss_check > 1 Then ; IF ping succeeded, pull the IP address from the ping response file *otherwise* Try to pull from the Registry if Ping Failed If $IsAlive = "Responding" Then ; all is good Else $keyread = "working" While $keyread = "working" $r = $r + 1 ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $IPSubkey = RegEnumKey(" & @CRLF) ;;FileFlush($trace) $IPSubkey = RegEnumKey("\\" & $strPCName & "\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\", $r) If @error <> 0 Then Select Case @error = -1 $keyread = "outofrange" Case @error = 3 $keyread = "Unable to connect to Registry" Case @error = 2 $keyread = "No such Key" Case @error = 1 $keyread = "No Subkey Found" EndSelect EndIf SetError(0) $IPkey = RegRead("\\" & $strPCName & "\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\" & $IPSubkey, "DhcpIPAddress") If $IPkey <> "" Then $keyread = "GotIt" EndIf SetError(0) WEnd If $IPkey = "" Then $IPkey = "Can Not.Acquire IP." & $keyread & ".Error" EndIf EndIf If $keyread = "GotIt" Or StringInStr($stripIP, ".") Then ; Take either method's IP address and pull out the subnet only ;MsgBox(0, "StringBetween", $stripIP[0]) $isip = StringInStr($stripIP, ".") If $isip > 0 Then $arrIP = StringSplit($stripIP, ".") ;MsgBox(0, "Array size for IP", $arrIP[0]) $strSubnet = $arrIP[1] & "." & $arrIP[2] & "." & $arrIP[3] Else If StringInStr($IPkey, ".") Then $arrIP = StringSplit($IPkey, ".") If $arrIP[0] > 3 Then $strSubnet = $arrIP[1] & "." & $arrIP[2] & "." & $arrIP[3] Else $strSubnet = $IPkey EndIf Else $strSubnet = $IPkey EndIf EndIf ; Check for the BMC Tuner File Select Case FileExists("\\" & $strPCName & "\C$\Program Files\marimba\tuner\tuner.exe") $TunerPath = "C Drive" Case FileExists("\\" & $strPCName & "\E$\Program Files\marimba\tuner\tuner.exe") $TunerPath = "E Drive" Case FileExists("\\" & $strPCName & "\D$\Program Files\marimba\tuner\tuner.exe") $TunerPath = "D Drive" Case FileExists("\\" & $strPCName & "\C$\Program Files (x86)\marimba\tuner\tuner.exe") $TunerPath = "C Drive 64" Case FileExists("\\" & $strPCName & "\E$\program files\BMC Software\BBCA\Tuner\tuner.exe") $TunerPath = "E BBCA" Case FileExists("\\" & $strPCName & "\D$\program files\BMC Software\BBCA\Tuner\tuner.exe") $TunerPath = "D BBCA" Case FileExists("\\" & $strPCName & "\U$\program files\marimba\tuner\tuner.exe") $TunerPath = "U Drive" Case FileExists("\\" & $strPCName & "\V$\program files\BMC Software\BBCA\Tuner\tuner.exe") $TunerPath = "V BBCA" Case FileExists("\\" & $strPCName & "\V$\program files\marimba\tuner\tuner.exe") $TunerPath = "V Drive" Case Else $TunerPath = "Z_No Tuner File" If Not StringInStr($strOS, "Server") And Not StringInStr($strOS, "NT") Then FileWriteLine($nobmcfile, $strPCName) EndIf EndSelect ; Check for the BMC Tuner Service $sTunerServicei = "" ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " For $Tservice In $servicenames" & @CRLF) ;;FileFlush($trace) For $Tservice In $servicenames $tsregread = RegRead("\\" & $strPCName & $services & "\" & $Tservice, "DisplayName") If $tsregread <> "" Then $sTunerServicei = $sTunerServicei & ";" & $tsregread EndIf Next ; clean up ; $sTunerServicei = StringTrimLeft($sTunerServicei, 1) ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $TrendServer = RegRead($trendkey" & @CRLF) ;;FileFlush($trace) $TrendServer = RegRead($trendkey & "\PC-cillinNTCorp\CurrentVersion", "Server") Select Case $TrendServer = 1 $TrendServer = "Unable to open Key" Case $TrendServer = 2 $TrendServer = "Trend Registry Not Found" Case $TrendServer = 3 $TrendServer = "Unable to Connect Registry" Case $TrendServer = -1 $TrendServer = "Value Not Found" Case $TrendServer = -2 $TrendServer = "Value Type Not Supported" EndSelect If $TrendServer = "" Then $TrendServer = RegRead("\\" & $strPCName & "\HKLM\SOFTWARE\Wow6432Node\TrendMicro\PC-cillinNTCorp\CurrentVersion", "Server") EndIf $drivespace = DriveSpaceFree("\\" & $strPCName & "\c$") CheckTunerService($strPCName) If $sTunerService = "Z_No Tuner Running" And $ExistingService <> "X" And $TunerPath <> "Z_No Tuner File" Then If StringInStr($ExistingService, ";") Then ; should get down to one service! Requires manual investigation Else ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & ' $startbmc = ShellExecute("sc.exe",' & @CRLF) ;;FileFlush($trace) $startbmc = ShellExecute("sc.exe", "\\" & $strPCName & " start " & $ExistingService, "", "", @SW_HIDE) Sleep(3000) CheckTunerService($strPCName) EndIf EndIf If $sTunerService = "Z_No Tuner Running" Then ; Check for Tuner.exe process (Windows 7) ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & ' $pscommand = $pslist & " \\" & $strPCName & " tuner.exe >> pslist.txt"' & @CRLF) ;;FileFlush($trace) $pscommand = $pslist & " \\" & $strPCName & " tuner.exe >> pslist.txt" Local $pwcmdproc $pwcmdproc = Run($pscommand, "", @SW_HIDE) Local $pwc = ProcessWaitClose($pwcmdproc, 60) If $pwc = 0 Then ProcessClose($pwcmdproc) EndIf $pslistfile = FileOpen("pslist.txt", $ForReading) $psfileread = FileRead($pslistfile) $pslistfound = StringInStr($psfileread, "CPU Time") If $pslistfound > 0 Then $sTunerService = "Tuner Process" EndIf EndIf ; Check Trend Service $qTrendService = _ServiceRunning($strPCName, "ntrtscan") If $qTrendService = 1 Then $sTrendService = "Trend Running" Else $sTrendService = "No Trend Running" If Not StringInStr($strOS, "Server") And Not StringInStr($strOS, "NT") Then FileWriteLine($notrendfile, $strPCName) ShellExecute("sc.exe", "\\" & $strPCName & " start ntrtscan") ShellExecute("sc.exe", "\\" & $strPCName & " start tmlisten") EndIf EndIf ; Check GoverLan Service $qGoverLan = _ServiceRunning($strPCName, "GOVsrv") If $qGoverLan = 1 Then $sGoverLan = "GoverLan Running" Else $sGoverLan = "No GoverLan Running" EndIf Else ProcessClose($WMITest) $sTunerService = "WMI Locked Up" $sTrendService = "WMI Locked Up" EndIf Else ProcessClose($WMITest) $sTunerService = "WMI Unavailable" $IsAlive = $IsAlive & ": WMI Locked (" & $exitcode & ")" EndIf ; Write the results to the Results file ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " FileWriteLine($LogFile" & @CRLF) ;;FileFlush($trace) FileWriteLine($LogFile, $strPCName & "," & $IsAlive & "," & $strOS & "," & $strOSsp & "," & $strOSv & "," & $strChanged & "," & $strCreated & "," & $strPwdChd & "," & $strSubnet & "," & $TunerPath & "," & $sTunerServicei & "," & $sTunerService & "," & $sTrendService & "," & $TrendServer & "," & $sGoverLan & "," & $drivespace & "," & $startbmc) Else ;FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " FileWriteLine($LogFile" & @CRLF) ;;FileFlush($trace) FileWriteLine($LogFile, $strPCName & "," & $IsAlive & "," & $strOS & "," & $strOSsp & "," & $strOSv & "," & $strChanged & "," & $strCreated & "," & $strPwdChd & "," & $strSubnet & "," & $TunerPath & "," & $sTunerServicei & "," & $sTunerService & "," & $sTrendService & "," & $TrendServer & "," & $sGoverLan & "," & $drivespace & "," & $startbmc) $recheck = $recheck & "!" & $fqdn EndIf ; Cleanup all variables, just to see if there is carryover and prevent contamination of next record $WMITest = "" $strPCName = "carryover" $IsAlive = "carryover" $strOS = "carryover" $strOSsp = "carryover" $strOSv = "carryover" $strChanged = "carryover" $strCreated = "carryover" $strSubnet = "carryover" $sTunerService = "" $sTrendService = "carryover" $strADGROUP = "carryover" $Groups = "carryover" $strSubnet = "carryover" $IPkey = "carryover" $TunerPath = "carryover" $sTunerServicei = "carryover" $sGoverLan = "carryover" $startbmc = "carryover" $ExistingService = "" $Locator = "" $Service = "" EndFunc ;==>InfoCollect Func CheckTunerService($strPCName) ;FileWriteLine($trace, "Line " & (@ScriptLineNumber - 1) & " Func CheckTunerService($strPCName)" & @CRLF) ;;FileFlush($trace) Dim $qTunerService, $qTunerServiceE $sTunerService = "" $Tservice = "" ; Check Tuner Services (some excluded) For $Tservice In $servicenames $qTunerService = _ServiceRunning($strPCName, $Tservice) $qTunerServiceE = _ServiceExists($strPCName, $Tservice) If $qTunerServiceE = 1 Then $ExistingService = $ExistingService & ";" & $Tservice EndIf If $qTunerService = 1 Then $sTunerService = $sTunerService & ";" & $Tservice EndIf Next ; If Z_No Tuner found then say so If $sTunerService = "" Then $sTunerService = "Z_No Tuner Running" EndIf ;clean up ExistingService $ExistingService = StringTrimLeft($ExistingService, 1) $sTunerService = StringTrimLeft($sTunerService, 1) EndFunc ;==>CheckTunerService ; This is my custom COM error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $timenow = @HOUR & ":" & @MIN FileWriteLine($ErrorFile, $strPCName & "," & $timenow & "," & $oMyError.description & "," & $HexNumber & ", Line " & $oMyError.scriptline & "," & $oMyError.windescription) $g_eventerror = 1 ; something to check for when this function returns EndFunc ;==>MyErrFunc Func ResultsCleanup() Dim $sfile, $search, $filecreated, $now, $datetest, $created $search = FileFindFirstFile("AssetCollect*.csv") If $search = -1 Then Return While 1 $sfile = FileFindNextFile($search) If @error Then ExitLoop $created = FileGetTime($sfile) $filecreated = $created[0] & "/" & $created[1] & "/" & $created[2] & " " & $created[3] & ":" & $created[4] & ":" & $created[5] $now = _NowCalc() $datetest = _DateDiff("D", $filecreated, $now) If $datetest > 14 Then FileDelete($sfile) EndIf WEnd $search = FileFindFirstFile("status*.txt") If $search = -1 Then Return While 1 $sfile = FileFindNextFile($search) If @error Then ExitLoop $created = FileGetTime($sfile) $filecreated = $created[0] & "/" & $created[1] & "/" & $created[2] & " " & $created[3] & ":" & $created[4] & ":" & $created[5] $now = _NowCalc() $datetest = _DateDiff("D", $filecreated, $now) If $datetest > 7 Then FileDelete($sfile) EndIf WEnd $search = FileFindFirstFile("Error*.csv") If $search = -1 Then Return While 1 $sfile = FileFindNextFile($search) If @error Then ExitLoop $created = FileGetTime($sfile) $filecreated = $created[0] & "/" & $created[1] & "/" & $created[2] & " " & $created[3] & ":" & $created[4] & ":" & $created[5] $now = _NowCalc() $datetest = _DateDiff("D", $filecreated, $now) If $datetest > 7 Then FileDelete($sfile) EndIf WEnd EndFunc ;==>ResultsCleanup ;Func ExitReport() ; $xitrpt = FileOpen(@ScriptDir & "\Exitreport.txt", 1) ; FileWriteLine($xitrpt, @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN) ; FileWriteLine($xitrpt, "Exit Code : " & @exitCode & @CRLF & "Exit Method : " & @exitMethod) ; FileClose($xitrpt) ; Exit ;EndFunc ;==>ExitReport Anyone have any ideas on why this is hanging up?? -
Script Locks Up [reopened]
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
I found : http://www.adras.com/Check-WMI-Connectivity.t3372-52.html Which suggests that using Dim $iSecurityFlags = "&H80" ; "wbemConnectFlagUseMaxWait" or 128 or &H80 not &H080 Works. "&H80" instead of "&H080" - so am trying this. No errors so far (26 systems) -
Script Locks Up [reopened]
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
Well, its not working. Its better, but I just verified with trace lines that the script hangs on : $Service = $Locator.ConnectServer($strPCName, "root/cimv2", "", "", "", "", $iSecurityFlags) (its either that line or "If IsObj($Service) Then") and will just sit there forever - even though it is supposed to time out. Here is a code snippit to test with - granted, the actual script (619 lines with an additional 6 includes) connects to active directory and goes through 500 to 700+ computers, pulling info from AD, WMI and direct file reads, before hanging on one. Its not usually the same system - I just verified the last run it zoomed past the computer name it hung up on this time. $strPCName = InputBox("PC Name","Input Computer Name") $Locator = ObjCreate("WbemScripting.SWbemLocator") Dim $iSecurityFlags = 128 ; "wbemConnectFlagUseMaxWait" or 128 or &H080 $Service = $Locator.ConnectServer($strPCName, "root/cimv2", "", "", "", "", $iSecurityFlags) If IsObj($Service) Then ; Test to see if the WMI Service is behaving $psscmd = " \\" & $strPCName & " query winmgmt" $WMITest = Run($psservice & $psscmd, "", @SW_HIDE) $pss_check = ProcessWaitClose($WMITest, 128) If $pss_check = 1 Then Msgbox(0,"WMI Test", $strPCName & " has responsive WMI.") Else Msgbox(0,"WMI Test", $strPCName & " has broken WMI.") Endif Else Msgbox(0,"WMI Test", $strPCName & " - can not connect." Endif My trace report got : Starting (Some Server Name) pc 574 Starting (Some Server Name) at 5/3/2011 3:42:22 PM Line 299 $pingresult = Run Ping Completed - 1123.9115747736 milliseconds Line 338 $Service = $Locator.ConnectServer and I saw this on 5/4/2011 at 8:20 AM With my Trace lines : $Locator = ObjCreate("WbemScripting.SWbemLocator") FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $Service = $Locator.ConnectServer" & @CRLF) FileFlush($trace) $Service = $Locator.ConnectServer($strPCName, "root/cimv2", "", "", "", "", $iSecurityFlags) If IsObj($Service) Then ; Test to see if the WMI Service is behaving $psscmd = " \\" & $strPCName & " query winmgmt" FileWriteLine($trace, "Line " & (@ScriptLineNumber + 2) & " $WMITest = Run($psservice & $psscmd" & @CRLF) FileFlush($trace) $WMITest = Run($psservice & $psscmd, "", @SW_HIDE) $pss_check = ProcessWaitClose($WMITest, 128) If $pss_check = 1 Then Includes in the big script : #include "String.au3" #include "ADFunctions.au3" #include "ServiceControl.au3" #include "array.au3" #include "Date.au3" #include "Constants.au3" -
Script Locks Up [reopened]
Graywalker replied to Graywalker's topic in AutoIt General Help and Support
That was not working consistently. In other words, I still got hangs, but nowhere near as often. I found iSecurityFlags = "&H80" over here So, code would be Global $psservice = @ComSpec & ' /c "' & @ScriptDir & '\psservice.exe"' ProgressSet($i, $pcc & " of " & $RecordCount & " - Checking for Running BMC Services", "Working on " & $strPCName) $iSecurityFlags = "&H80" $Locator = ObjCreate("WbemScripting.SWbemLocator") $Service = $Locator.ConnectServer($strPCName, "root/cimv2", "", "", "", "", $iSecurityFlags) $Locator = ObjCreate("WbemScripting.SWbemLocator") Dim $iSecurityFlags = 128 $Service = $Locator.ConnectServer($strPCName, "root/cimv2", "", "", "", "", $iSecurityFlags) also works - and I've used it with good results so far. -
Well, I worked around it by: Using Gimp to extract and save each icon to it's own .ico file. Downloaded and installed IcoFX and used it's Resource Editor to add each .ico and save it as an .icl (Icon List) file. Now : GUICtrlSetImage($heartbeat, "BK_Set.icl", 1); Icon #1 - black, Icon #2 - green, Icon #3 - red, Icon #4 - yellow works fine. Apparently, the SetImage doesn't actually work with multiple Icon files - only .dll, .exe, .icl and other "resource" files to pull out the icon from those compiled sources. So GUICtrlSetImage($heartbeat, "heart_red.ico") would work fine, but not GUICtrlSetImage($heartbeat, "hearts_.ico",3) - that would show the first icon in the .ico - or nothing. To use multiple icons in one file you need a compiled resource. With those, yes, a resource hacker would find the proper name for the icon I was seeking. Resource hackers do nothing on .ico files... lol!
-
The Remarks on GuiCtrlSetImage state : Like what?? I've downloaded and tried Reshack - but the .ico is not a valid exe or resource file - so no go there. I opened the file with Gimp and the layers are named "Icon #1" through "Icon #4" - It has four icons in it and I've tried "Icon #4" and such - no good. I've tried "22", "24", etc... no good. So, How do I know what "name" the icon I want from the .ico file is?? Global $heartbeat = GUICtrlCreateButton("",610,02,32,32,$BS_ICON) GUICtrlSetImage($heartbeat,"redlight_hearts.ico","Icon #4") ; Icon #1 - yellow, Icon #2 - red, Icon #3 - green, Icon #4 - black
-
Yep. I feel like the bird that flew into the window. DOAH!! Anyway - thank you very much. Below code works nicely. May have unnecessary includes. If you are a systems admin and sometimes remote to user's computers - now you don't have to keep asking "is it back to the log-on screen yet?" after having them reboot. (as long as its on your network) You can use the IP address as well. ; Heartbeat Monitor for Remote Systems #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $status = "off", $ComputerName, $ts, $td, $pc = 0, $i = 0, $PCName #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Monitor", 226, 74, 272, 140) $ComputerName = GUICtrlCreateInput("computername", 96, 8, 121, 21) $Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17) $Button1 = GUICtrlCreateButton("Status", 8, 32, 211, 33, 0) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### ;ProgressOn("Testing","Running?","",5,5,16) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ;MsgBox(0, "Variables", $status & @CRLF & $td & @CRLF & $ts & @CRLF & $pc & @CRLF) Exit Case $Button1 Buttonclick() Case Else ;$i = $i + 1 ;If $i > 100 Then $i = 1 ;ProgressSet($i,$td) $PCName = GUICtrlRead($ComputerName) If $PCName <> "computername" Then If $status = "on" Then $td = TimerDiff($ts) If $td > 10000 Then _ping() EndIf EndIf EndIf EndSwitch WEnd Exit Func Buttonclick() If $status = "on" Then $status = "off" GUICtrlSetBkColor($Button1, 0x999999) ; medium gray GUICtrlSetData($Label1, "Computer Name") GUICtrlSetData($Button1,"Status") $ts = 0 $pc = 0 Return $status Else $status = "on" $PCName = GUICtrlRead($ComputerName) GUICtrlSetBkColor($Button1, 0xffff99) ; light yellow $ts = 0 $pc = 0 Return $status EndIf EndFunc ;==>Buttonclick Func _ping() Dim $pr = 1 $PCName = GUICtrlRead($ComputerName) $pc = $pc + 1 $ts = TimerInit() $pr = Ping($PCName) If $pc = 1 Then Sleep(200) $pr = Ping($PCName) EndIf If $pr = 0 Then Select Case @error = 1 GUICtrlSetData($Button1,"Offline") Case @error = 2 GUICtrlSetData($Button1,"Unreachable") Case @error = 3 GUICtrlSetData($Button1,"Bad Destination") Case @error = 4 GUICtrlSetData($Button1,"Not Repsonding") EndSelect GUICtrlSetBkColor($Button1, 0xFF3300) ; Red Else GUICtrlSetBkColor($Button1, 0x00cc00) ; Green GUICtrlSetData($Button1,"Repsonding") EndIf GUICtrlSetData($Label1, " " & $pc & " Pings") $ts = TimerInit() Return $ts EndFunc ;==>_ping