ghoomp Posted April 27, 2015 Posted April 27, 2015 Hi all, Can someone help me with the BgInfo? I am deploying an image for users but I would like to add a BgInfo in the image. I already fixed for the IP address and MAC address but I have a problem with the Network Type and Free Space. For the network type it shows me 3 types -> Ethernet, Ethernet 2 and Local Area Connection. I would like that it shows me only one active connection with. Like connected with wifi or network cable. This is the query that I have -> SELECT NetConnectionID FROM Win32_NetworkAdapter where NETEnabled = 'True' For the free space it shows me the local drives and the network drives. I want a query only for the C: drive in Gigabyte. SELECT FreeMegabytes FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk WHERE Name='C:' It shows me for example 3000, there is no description in Mb. If someone can sort it out for me I would be really thankfull. Thanks for your help guys.
spudw2k Posted April 27, 2015 Posted April 27, 2015 Found this article:https://social.technet.microsoft.com/Forums/en-US/ab770ca1-134b-4fe4-8e16-c1e65c51a23a/wmi-query-to-return-freespace-drive-name-and-size-of-disk-in-windows-server?forum=ITCG Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
UEZ Posted April 27, 2015 Posted April 27, 2015 (edited) Does this work for you? expandcollapse popupGlobal Const $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler") Global $aNetInfo = _WMI_GetInfoFromActiveNetworkCard() Global $fCDriveFreeSpace = _WMI_GetCDriveFreeSpace() MsgBox(0, "Test", "Adapter:" & @TAB & $aNetInfo[0] & @CRLF & _ "MAC:" & @TAB & $aNetInfo[1] & @CRLF & _ "IP:" & @TAB & $aNetInfo[2] & @CRLF & _ "Subnet:" & @TAB & $aNetInfo[3] & @CRLF & _ "Gateway:" & @TAB & $aNetInfo[4] & @CRLF & @CRLF & _ "Free space on C drive: " & $fCDriveFreeSpace & " GB") Func _WMI_GetInfoFromActiveNetworkCard($sHost = @ComputerName) Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $iInterfaceIndex, $objItem, $colItems2, $objItem2 Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'", "WQL", 0x30) If IsObj($colItems) Then Local $aActiveNetworkAdapter[5] For $objItem in $colItems $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE InterfaceIndex = " & $objItem.InterfaceIndex, "WQL", 0x30) For $objItem2 in $colItems2 $aActiveNetworkAdapter[0] = $objItem2.Description $aActiveNetworkAdapter[1] = $objItem2.MACAddress $aActiveNetworkAdapter[2] = $objItem2.IPAddress[0] $aActiveNetworkAdapter[3] = $objItem2.IPSubnet[0] $aActiveNetworkAdapter[4] = $objItem2.DefaultIPGateway[0] Return $aActiveNetworkAdapter Next Next Else Return SetError(2, 0, 0) EndIf EndFunc Func _WMI_GetCDriveFreeSpace($sHost = @ComputerName) Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk WHERE Name = 'C:'", "WQL", 0x30), $objItem If IsObj($colItems) Then For $objItem in $colItems Return Round($objItem.FreeMegabytes / 1024, 2) Next Else Return SetError(2, 0, 0) EndIf EndFunc Func ObjErrorHandler() ConsoleWrite( "A COM Error has occured!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _ "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _ ) EndFunc Edited April 28, 2015 by UEZ Changed function name Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
ghoomp Posted April 28, 2015 Author Posted April 28, 2015 Hi UEZ, thanks for your feedback but when I am running the script it says Line 1 and char 8 gives a syntax error. Code 800A03EAI am also not so familiar with VB script :-(
UEZ Posted April 28, 2015 Posted April 28, 2015 (edited) Which operating system are you using? It works properly on my Win 8.1 notebook. Edited April 28, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
UEZ Posted April 28, 2015 Posted April 28, 2015 (edited) Anybody else with a problem running the code from above?@ghoomp: this is not a VB Script! You have to run it either in SciTE or compile and run it. Edited April 28, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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