kevinward13 Posted May 27, 2011 Share Posted May 27, 2011 Dont want to go into a lot of great detail as to what I am working towards, but it is not, and i repeat, NOT the forbidden subjects. Plus I read somewhere it is a big red flag to ask for code without trying it first. So i have been doing a lot of digging and reading to get this far, I dont understand it 100% yet, more like 10% but i have been pulling snippets here and there to get what I am looking for. If you see bits and pieces of your code, please let me know so i can give credit where credit is due. By no means is this all my work. I am trying to get small ammounts to work seperatly before i get them all to fit together. Here is what I have now expandcollapse popupGlobal $ip = "localhost" If $CmdLine[0] > 0 Then $ip = $CmdLine[1] $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2") _WMI($ip) Exit Func _WMI($srv) Local $ping, $colItems, $objItem, $ComputerName, $OS, $SP, $Disk, $Disk_Caption, $Disk_FreeSpace, $Disk_Perc_Free, $Disk_Size $ping = Ping($srv) If $ping Then $colItems = $objWMIService.ExecQuery("Select CSName, Caption, CSDVersion from Win32_OperatingSystem", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $ComputerName = $objItem.CSName $OS = $objItem.Caption $SP = $objItem.CSDVersion Next ConsoleWrite($ComputerName & @CRLF & $os & @CRLF & $SP & @CRLF) EndIf $colItems = $objWMIService.ExecQuery("Select Caption, FreeSpace, MediaType, Size from Win32_LogicalDisk Where MediaType = '12'", "WQL", 0x30) ;get fixed harddisk media If IsObj($colItems) Then For $objItem In $colItems If $objItem.Size > 0 And $objItem.MediaType <> "" Then $Disk_Caption = $objItem.Caption $Disk_FreeSpace = Round($objItem.FreeSpace / 1024 ^ 3, 2) $Disk_Size = Round($objItem.Size / 1024 ^ 3, 2) $Disk_Perc_Free = Round(100 * $objItem.FreeSpace / $objItem.Size, 2) $Disk &= $Disk_Caption & @CRLF & $Disk_Size & @CRLF & $Disk_FreeSpace & @CRLF EndIf Next ;ConsoleWrite($Disk & @CRLF & $Disk_Size & " GB" & @CRLF & $Disk_Perc_Free & " GB" & @CRLF) ConsoleWrite($Disk & @CRLF & @CRLF) EndIf Else Return "Host not reachable" EndIf EndFunc Just trying to gather small information about the comptuer. easy right? Well here is where the math doesnt add up for me. The above code works like it should. (pulled snippet) But when I tried to make some modifications to it so i can make it display to my likings...the math doesnt add. $Disk &= $Disk_Caption & @CRLF & $Disk_Size & @CRLF & $Disk_FreeSpace & @CRLF EndIf Next ;ConsoleWrite($Disk & @CRLF & $Disk_Size & " GB" & @CRLF & $Disk_Perc_Free & " GB" & @CRLF) ConsoleWrite($Disk & @CRLF & @CRLF) the above 1st and 5th lines are the original code. outputs the below which is correct. WLOS07E490 Microsoft Windows XP Professional Service Pack 3 C: 74.44 34.62 However when i comment out the 1st and 5th lines and un-comment ConsoleWrite($Disk & @CRLF & $Disk_Size & " GB" & @CRLF & $Disk_Perc_Free & " GB" & @CRLF) the math does not add up. It gives me this: WLOS07E490 Microsoft Windows XP Professional Service Pack 3 74.44 GB 46.51 GB Any ideas? Link to comment Share on other sites More sharing options...
BrewManNH Posted May 27, 2011 Share Posted May 27, 2011 $Disk_Perc_Free isn't that the percentage free, and not the free space, going by the variable name you used. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kevinward13 Posted May 27, 2011 Author Share Posted May 27, 2011 you are correct. I just caught that when i looked at and was talking to my self aloud. I didnt pay my syntax and i got nailed Link to comment Share on other sites More sharing options...
kevinward13 Posted May 27, 2011 Author Share Posted May 27, 2011 Changed $Disk_Perc_Free to this $Disk_FreeSpace Link to comment Share on other sites More sharing options...
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