Jump to content

pcmerc

Members
  • Posts

    11
  • Joined

  • Last visited

pcmerc's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Ok, I'm getting data now. Thanks alot. Now I need to fine tune it to display it in bits per second. This should do it. $BytesSent = $objItem.BytesSentPersec * 8 / 1000
  2. changed the following line $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Error went away. I to am getting 0. When the script is run normally it returns the aggregated bytes sent from all interfaces. I guess it's possible that the code here For $objItem In $colItems $BytesSent = $BytesSent + ObjGet("objItem.BytesSentPersec") would be responsible for returning the information we're looking for. Where is the $ObjItem defined? Maybe we need to define that prior.
  3. Using the changed code I get the following error now: C:\Test\test.au3 (39) : ==> Variable must be of type "Object".: $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $colItems = $objWMIService^ ERROR
  4. Returns 0 when your downloading a file?
  5. #include <Array.au3> _ArrayCreate ( $v_Val1, [$v_Val2, [..., $v_Val21]] )
  6. Ran with following errors. C:\Test\test.au3(39,112) : ERROR: syntax error $colItems = ObjGet($objWMIService&.ExecQuery "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~^ C:\Test\test.au3(39,170) : ERROR: ObjGet() [built-in] called with wrong number of args. $colItems = ObjGet($objWMIService&.ExecQuery "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Test\test.au3(39,171) : ERROR: syntax error $colItems = ObjGet($objWMIService&.ExecQuery "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Test\test.au3(42,19) : ERROR: 'Return' not allowed from global scope. Return ~~~~~~~~~~~~~~~~~~^ C:\Test\test.au3 - 4 error(s), 0 warning(s)
  7. Thankyou. I'll test it & reply. I'm also going to study it so I can better understand the difference between autoit's com functionality as opposed to straight vbs. Thanks again.
  8. Could I please get some help converting this code to autoit? I don't have enough experience with COM object programming to do it myself. I've been hacking at it but I'm sure I'm going about it all wrong. This is what I need to convert: On Error Resume Next Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20 arrComputers = Array("localhost") int BytesSent = 0 For Each strComputer In arrComputers Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly) For Each objItem In colItems BytesSent = BytesSent + objItem.BytesSentPersec Next Next WScript.Echo BytesSent This is what I've come up with so far: Const $wbemFlagReturnImmediately = "&h10" Const $wbemFlagForwardOnly = "&h20" $arrComputers = _ArrayCreate("localhost") $BytesSent = 0 ;For Each strComputer In arrComputers $objWMIService = ObjGet("winmgmts:\\" & "strComputer" & "\root\CIMV2") $colItems = ObjGet($objWMIService&.ExecQuery "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface", "WQL"); _ ; $wbemFlagReturnImmediately + $wbemFlagForwardOnly)) ; For Each objItem In colItems $BytesSent = $BytesSent + ObjGet("objItem.BytesSentPersec") ; Next ;Next ; WScript.Echo BytesSent MsgBox(0, "Test", $BytesSent) Any insight would extremely helpful as well as I'm trying to learn, Thanks!
  9. Nevermind figured it out.
  10. I'm having some problems getting this code to work. When passing a variable argument to the Run command item in the following code: This basically pulls a file down from my website. Unzips it & runs the virus scan. I'd then like the log emailed once it's completed. For some reason the $serverinfo variable doesn't get passed into the Run command. If I hardcode the username/serverIP or name it then works. What are the limitations of using a variable within a Run command? I just need some direction if possible please. Thanks! #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.5 Prototype #include <GuiConstants.au3> ; If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GuiCreate("TrendMicro Virus Scan", 211, 189,(@DesktopWidth-211)/2, (@DesktopHeight-189)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $Input_1 = GuiCtrlCreateInput("Enter Name or IP", 10, 40, 150, 20) ;$Input_2 = GuiCtrlCreateInput("", 10, 140, 50, 20) $Label_3 = GuiCtrlCreateLabel("Name or Server IP", 10, 20, 150, 20) ;$Label_4 = GuiCtrlCreateLabel("Time", 10, 120, 60, 20) ;$Input_5 = GuiCtrlCreateInput("", 10, 90, 190, 20) ;$Label_6 = GuiCtrlCreateLabel("Email Address", 10, 70, 190, 20) $StartButton = GuiCtrlCreateButton("Start", 110, 140, 90, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $StartButton DoCode(GUICtrlRead($Input_1)) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func DoCode($serverinfo) ; Connect ssh with account@server use wget to pull the tsc.zip down to the local hdd in the root of C Run("c:\tsc\ssh.exe administrator@$serverinfo wget -c -m -nH 'http://www.pcmerc.com/tsc.zip' -P '/cygdrive/c/'","", @SW_SHOW) ; Connect ssh with account@server make directory tsc in the root of C ; Run("ssh.exe 'administrator@$IPaddress' mkdir '/cygdrive/c/tsc'","", @SW_HIDE) ; Connect ssh with account@server unzip tsc.zip to the directory tsc in the root of C ; Run("ssh.exe 'administrator@$IPaddress' unzip -d '/cygdrive/c/tsc /cygdrive/c/tsc.zip'","", @SW_HIDE) ; Connect ssh with account@server run a virus scan from the directory tsc in the root of C ; Run("ssh.exe 'administrator@$IPaddress' '/cygdrive/c/tsc/syclean.com /NOGUI /SILENT c:\ /Y'","", @SW_HIDE) EndFunc #endregion --- GuiBuilder generated code End ---
  11. Any1 have any ideas for having autoit check a particular process's current CPU usage percentage, if 85% usage for a certain amount of time, then do
×
×
  • Create New...