Jump to content
Sign in to follow this  
Xonos

Quick Question

Recommended Posts

Xonos

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]

Share this post


Link to post
Share on other sites
iamtheky

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 by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
mdwerne

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

Share this post


Link to post
Share on other sites
mdwerne

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. :graduated:

Share this post


Link to post
Share on other sites
mdwerne

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

Share this post


Link to post
Share on other sites
mdwerne

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... :graduated:

-Mike

Share this post


Link to post
Share on other sites
Xonos

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]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×