Jump to content
Sign in to follow this  
Tim Net

WMI, ADSI and AutoIT.

Recommended Posts

I have an app written in AutoIT that periodically checks and possibly disconnections connections to a server. The script uses NET.EXE("NET SESSION"), QUERY.EXE("QUERY SESSION" in DOS), RESET.EXE("RESET SESSION") and NET.EXE(for "NET USER"). I have found the versions of NET.EXE, QUERY.EXE and RESET.EXE on the servers to be less reliable and would like to switch to WMI or ADSI.

So, instead of using text files as output from the following commands, I would like to have AutoIT call available objects. Here's what I have already replaced:

Old Code:

RunWait (@ComSpec & ' /C NET USER ' & $USER_ACCOUNT & ' "' & $NEW_PASSWORD & '" ', @ScriptDir, @SW_HIDE)

New Code:

$WMI_USER_OBJECT = OBJGET("WinNT://" & @computername & "/" & $MANAGED_USER_ACCOUNT_NAME & "")

Question #1: While this works fine, is there anything better that I nees to do with the object?

Here are the remaining sections that need to be converted to WMI or ADSI.

Question #2: RUNWAIT (@comspec & ' /C QUERY.EXE SESSION "User"',@scriptdir,@sw_hide)

--This will find out who is connected via Remote Desktop--

Question #3: Run (@ComSpec & ' /C RESET SESSION 2',@scriptdir,@sw_hide)

--This will disconnect a session from Remote Desktop--

Question #4: RUNWAIT (@comspec & ' /C NET.EXE SESSION ', $BIN_LOCATION, @SW_HIDE)

--This will find out who has an RPC connection open--

Question #5: Run (@ComSpec & ' /C NET SESSION \\ /DELETE /Y ', $BIN_LOCATION, @SW_HIDE)

--This will disconnect connections from a device--

How do I make these calls? I don't want to rely on the NET,QUERY and RESET binaries and also can't pack them in myself. I have sees reference to "select * from win32_terminal" but can't figure out how to use such a command in AutoIT.

I have downloaded scriptomatic and WMITools and hope that someone has seen/done this before.



Share this post

Link to post
Share on other sites

Hi, it's been two years, but did anybody have an answer for you on doing the commands in WMI? Specifically "query session" and "reset session" are the ones I'd like to do myself.

Using Run() and the commands hasn't failed me yet, but it would help, just in case I run across a computer/server that doesn't allow cmd to run, for example.

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  

  • Create New...