Jump to content

Check status from local account


Recommended Posts

Hi,

just want to know is there a way to check the status from a local user account like the administrator.

Want to know if the account is active or disabled etc.

I know with net user I can do some modifications, but found no syntax for checking the status.

Thanks a lot.

Link to comment
Share on other sites

All kinds of goodies like that available from the WMI interface:

$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
$colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE LocalAccount = True")
For $oItem in $colItems
    ConsoleWrite("Name = " & $oItem.Name & "; Disabled = " & $oItem.Disabled & @LF)
Next

To do that for a particular user:

$sUser = "YourUserNameHere"
$oWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
$colItems = $oWMIService.ExecQuery("SELECT * FROM Win32_UserAccount WHERE LocalAccount=True AND Name='" & $sUser & "'")
For $oItem in $colItems
    ConsoleWrite("Name = " & $oItem.Name & "; Disabled = " & $oItem.Disabled & @LF)
Next

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks PsaltyDS.

Just don't know to handle the code.

Have never used WMI or ConsoleWrite.

When I copy the code and run it, nothing happens.

In the help I found this:

This does not write to a DOS console unless the script is compiled as a console application..

How do I compile the code as a console application?

Maybe someone can help me a little bit how to use the code.

Thanks a lot.

Link to comment
Share on other sites

Try it first in Scite4Autoit. There is an Output pane (press F8) which shows the ConsoleWrites!

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

In the help I found this:

This does not write to a DOS console unless the script is compiled as a console application..

How do I compile the code as a console application?

What Xenobiologist said. I write most of my demos to be run from SciTE and display results in the console there, because MsgBox()s are too annoying.

If you should want to create a console app, just add this to the top of your script:

#AutoIt3Wrapper_Change2CUI=Y

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...