Xonos Posted October 6, 2011 Share Posted October 6, 2011 I am writing a utility that will allow me to run commands as another user within my network (AD) when logged onto the system as another user with bare minimum privileges. This utility will have a number of things however I did get stumped on something very small. I need to obtain the "Computer Description" into a variable but I haven't had any luck finding anything remotely close to that. All I could really find was getting network adapter descriptions and that's it.If you're wondering what I mean by Computer Description, it's a field next to changing your computer hostname. Does anyone know of any undocumented macros or something for this? I use computer description for barcodes on over 3000+ systems and this could help tremendously if I need to change it or simply verify that it's correct on local systems. [center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center] Link to comment Share on other sites More sharing options...
iamtheky Posted October 6, 2011 Share Posted October 6, 2011 (edited) Its written a couple places in my registry, dont know if its consistent across all systems but this works for me *for verification $Description = regread("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComputerDescriptions" , @ComputerName) msgbox (0, '' , $Description) Edited October 6, 2011 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mdwerne Posted October 6, 2011 Share Posted October 6, 2011 How about WMI? Does this get you what you need? ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "S916565" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Description: " & $objItem.Description & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc -Mike Link to comment Share on other sites More sharing options...
mdwerne Posted October 6, 2011 Share Posted October 6, 2011 How about WMI? Does this get you what you need? ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "S916565" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Description: " & $objItem.Description & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc -Mike Yeah, that's not it...sorry. Still looking. Link to comment Share on other sites More sharing options...
mdwerne Posted October 6, 2011 Share Posted October 6, 2011 Its written a couple places in my registry, dont know if its consistent across all systems but this works for me *for verification $Description = regread("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComputerDescriptions" , @ComputerName) msgbox (0, '' , $Description) Here is another registry location, just for grins: $Description = regread("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lanmanserver\parameters" , "srvcomment") msgbox (0, '' , $Description) -Mike Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 6, 2011 Share Posted October 6, 2011 Check _ComputerGetOSs() from for how to do it with WMI .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
mdwerne Posted October 6, 2011 Share Posted October 6, 2011 AH HA!!! The right WMI query!!! ; Generated by AutoIt Scriptomatic $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "S916565" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Description: " & $objItem.Description & @CRLF if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $Output="" Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_OperatingSystem" ) Endif Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc Now I can nap again... -Mike Link to comment Share on other sites More sharing options...
Xonos Posted October 7, 2011 Author Share Posted October 7, 2011 Ahhh, WMI. I was looking into WMI but I wasn't sure if I should go that route. Guys, thanks for your help. I really didn't want anyone to "write it out" for me but as always, this community pushes me into the right direction. I appreciate it!! I'm getting a lot better with autoit. [center][/center][center]Xonos Development[font=trebuchet ms,helvetica,sans-serif]- Resources -[/font]AutoIT Documentation | Active Directory UDF | Windows Services UDF | Koda GUI Designer[/center] 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