Sign in to follow this  
Followers 0
Baz

vbs obj to Autoit

3 posts in this topic

Hi all.

The following is a vbs script I found on the Internet but I would like to change it to an Autoit script. Are you able to help? It is way above me.

Thanks

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount",,48)

For Each objItem in colItems

Wscript.Echo "AccountType: " & objItem.AccountType

Wscript.Echo "Domain: " & objItem.Domain

Wscript.Echo "FullName: " & objItem.FullName

Wscript.Echo "Name: " & objItem.Name

Next

Share this post


Link to post
Share on other sites



might want to search for Scriptomatic in scripts and scraps :D

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccountType: " & $objItem.AccountType & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "Disabled: " & $objItem.Disabled & @CRLF
      $Output = $Output & "Domain: " & $objItem.Domain & @CRLF
      $Output = $Output & "FullName: " & $objItem.FullName & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "LocalAccount: " & $objItem.LocalAccount & @CRLF
      $Output = $Output & "Lockout: " & $objItem.Lockout & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PasswordChangeable: " & $objItem.PasswordChangeable & @CRLF
      $Output = $Output & "PasswordExpires: " & $objItem.PasswordExpires & @CRLF
      $Output = $Output & "PasswordRequired: " & $objItem.PasswordRequired & @CRLF
      $Output = $Output & "SID: " & $objItem.SID & @CRLF
      $Output = $Output & "SIDType: " & $objItem.SIDType & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" )
Endif

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you very much gafrost.

One error with the "install date" line but I didn't need that.

Cheers

Baz

might want to search for Scriptomatic in scripts and scraps :D

; Generated by AutoIt Scriptomatic

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output = $Output & "Computer: " & $strComputer  & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_UserAccount", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output & "AccountType: " & $objItem.AccountType & @CRLF
      $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
      $Output = $Output & "Description: " & $objItem.Description & @CRLF
      $Output = $Output & "Disabled: " & $objItem.Disabled & @CRLF
      $Output = $Output & "Domain: " & $objItem.Domain & @CRLF
      $Output = $Output & "FullName: " & $objItem.FullName & @CRLF
      $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
      $Output = $Output & "LocalAccount: " & $objItem.LocalAccount & @CRLF
      $Output = $Output & "Lockout: " & $objItem.Lockout & @CRLF
      $Output = $Output & "Name: " & $objItem.Name & @CRLF
      $Output = $Output & "PasswordChangeable: " & $objItem.PasswordChangeable & @CRLF
      $Output = $Output & "PasswordExpires: " & $objItem.PasswordExpires & @CRLF
      $Output = $Output & "PasswordRequired: " & $objItem.PasswordRequired & @CRLF
      $Output = $Output & "SID: " & $objItem.SID & @CRLF
      $Output = $Output & "SIDType: " & $objItem.SIDType & @CRLF
      $Output = $Output & "Status: " & $objItem.Status & @CRLF
      if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_UserAccount" )
Endif

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  
Followers 0