Jump to content

Problem with PSEXEC.EXE, ControlSetText on Windows Server 2008 R2


Recommended Posts

Hi,

I am trying to use an AutoIt application run from PSEXEC.EXE on a Windows 2008 R2 server but have come across a problem with ControlSetText().

The Windows 2008 R2 server has User Account Control (UAC) disabled.

The problem can be demonstrated with the following AutoIt code.  Compile the following AutoIT to an executable, say "test.exe".

WinActivate("[CLASS:Notepad]")
WinWaitActive("[CLASS:Notepad]")
ControlSetText("[CLASS:Notepad]", "", "Edit1", "This is some 
test text")
 

 

On the 2008 R2 server start two cmd.exe A and B.

On cmd.exe A, type the following

  psexec.exe 127.0.0.1 -u <username> -p <password> -i 1 cmd.exe

using the same username and password as used to login.

Another cmd.exe window C appears.

Now start notepad on cmd.exe B.

  notepad.exe

Run the AutoIt script from cmd.exe C

  test.exe

and no text appears in the the notepad window.

Run the same AutoIt script from cmd.exe B

  test.exe

and the text "This is some test text" is written to notepad.

Quit notepad and now start it again but this time from cmd.exe C.

This time the application test.exe only works if run from cmd.exe C. It seems to be a permissions problem but I can find no difference in permissions between cmd.exe B and C.  Does anyone have any ideas what the problem might be?

Link to comment
Share on other sites

Hi,

I typed whoami /all in both cmd.exe B and C (the one spawned from PSEXEC).  The only difference I could see was that cmd.exe B had the additional group of LOCAL S-1-2-0.  Other than that, the two printouts were identical.

Since the original post, I have found a workaround to use ControlSend() with the string

"{HOME}+{END}{DEL}" & "This is some test text"

but I am still intrigued to know why ControlSetText() does not. 

Also ControlCommand() with "EditPaste" seems to be able to append text to what is already there.  But since I need to delete the original text, I went with the ControlSend() solution.

Link to comment
Share on other sites

Hi,

I found the ControlSend() solution in the above post a bit unrealiable and have come up with a better solution which I include here in case anyone else comes across the same problem.

#include <GuiEdit.au3>

; Function to write text to an edit box on Windows 2008
Func ControlSetText2008($title, $text, $controlID, $newText)    
    Local $hWnd = ControlGetHandle($title, $text, $controlID)
    _GUICtrlEdit_SetSel($hWnd, 0, -1)    
    _GUICtrlEdit_ReplaceSel($hWnd, $newText)
EndFunc   ;==>ControlSetText2008
 

 I found _GUICtrlEdit_SetText() suffers from the same problem as ControlSetText().  Also I am compiling the AutoIt on Server 2003 32-bit and running the compiled AutoIt on Server 2008 R2 64-bit.  I don't know if that has any influence on this problem.

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