Sign in to follow this  
Followers 0
MikhsilSV

Not working if launched by PsExec on remote PC

11 posts in this topic

#1 ·  Posted (edited)

script.au3:

RunWait("\\Server\share\SomeApp.exe")
WinWaitActive("Test click inactive desktop", "Button&2")
Send("!2")

 

On admin machine executing:

psexec \\RemotePC -s \\server\share\script.exe

Buttons remains unclicked

edit: by running usual way fails too

Edited by MikhsilSV

Share this post


Link to post
Share on other sites



@MikhsilSV What if you run PSEXEC with the -i (interactive) switch in addition to -s?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This is my normal command line layout for psexec..

 

psexec \\Computername -accepteula -i -c -f MyApp.exe

(in addition to what JLogan3o13 said )

Works every time

 

-accepteula This flag supresses the display of the license dialog.

-c         Copy the specified program to the remote system for
           execution. If you omit this option the application
           must be in the system path on the remote system.
           
 -i         Run the program so that it interacts with the desktop of the
            specified session on the remote system. If no session is
            specified the process runs in the console session.
            
 -f         Copy the specified program even if the file already
           exists on the remote system.

 

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Doubt the SEND() command will work when running with different credentials on the target machine. 

Might want to try ControlSend() or ControlClick()

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

If you want to run it as someone else, you can always hard code the creds.. I use this to elevate permissions for certain apps. Just know if the PW expires, you will have to recompile..

 

If NOT isadmin() Then
        RunAs("Administrator","MyDomain", "MyAdminPassword", 0, @ScriptFullPath & " on", "", @SW_SHOWMINIMIZED)
        Exit
EndIf

 

This will cause the script to relaunch under new creds, that may help.


C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Jos is of course correct, I missed that you were doing a Send rather then ControlSend. If you are unable to interact with the window controls, you are going to find it nigh impossible to run remotely.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Sorry for long time. I encount several issues while enforcing to work unattend installation of foobar2000 v1.3.9

I try to solve it by suggestions from this topic and my ideas, a lot of things. With no success.

My last version of script (unwork, even by doubleclecking it):

Local $vCaption = "foobar2000 v1.3.9 Setup"
Local $SRC = "\\Server\someshare\foobar2000_v1.3.9.exe"

RunWait($SRC)
sleep(300) ;just for any case
Local $hWnd=WinWaitActive($vCaption, "&Next >", 500)
;Send("!n") ;i tryes this first
Local $R=ControlClick($hWnd,"","[CLASSNN:Button2]")
if $R==0 then
   Exit(-5)
endif

WinWaitActive($vCaption, "I &Agree")
Send("!a")

WinWaitActive($vCaption, "&Next >")
Send("!n")

WinWaitActive($vCaption, "&Next >")
Send("!n")

WinWaitActive($vCaption, "&Install")
Send("!i")

WinWaitActive($vCaption, "&Run foobar2000")
Send("!r")

WinWaitActive($vCaption, "&Finish")
Send("!f")

I work on Win7 x64 Sp1+Ups if it something means

Can anyone write working scritp??? This one app is not life-critical, but i want how to fight with similar issues

Also tries clicking on TButton-s in super-simple GUI APP created & compiled in Lazarus, it s completely unclickable!

Share this post


Link to post
Share on other sites

MikhsilSV,

foobar2000 has /s switch for silent install. have you tried it?

(requires elevation of course, but PsExec handles that for you, with the -h switch)

B.T.W. welcome to AutoIt and to the forum!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

MikhsilSV,

foobar2000 has /s switch for silent install. have you tried it?

This is cause  why i throw a glance on AutoIt side. Some apps has broken silent install ability, some has unneded payload enabled by default.

Edited by MikhsilSV

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

i just downloaded and installed silently (Win10 elevated command prompt with /S switch) the latest stable release (v1.3.9).

i see no junk payload.

i did notice this: the switch is case-sensitive, i.e. should be /S not /s.

EDIT: also works over PsExec.

 

Edited by orbs
additional information

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

 

i did notice this: the switch is case-sensitive, i.e. should be /S not /s.

EDIT: also works over PsExec.

 

Just tried and ... Success! Previously i used exect /s switch. Thanks for hint!

Edited by MikhsilSV

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

  • Similar Content

    • Duck
      By Duck
      I'm attempting to capture the output from the command line tool PSEXEC. I'm using AutoIT to run an instance of PSEXEC against a remote PC to audit Local Admins in my environment using net.exe (C:\Windows\System32> net localgroup administrators). However the usual trick I use to capture command line output does not appear to work well with PSEXEC, as the bottom portion of the output is missing from the return. Any ideas or recommendations are greatly appreciated.  
       
      Here is what I'm working with: 
      ;This script will read from a list of hosts and report who has local admin privileges on the machine #RequireAdmin Global $fileName = @ScriptDir & '\test.txt' ;hostlist, one host per line readHostList() ;Read list of hosts Func readHostList() Local $file = FileOpen($fileName, 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ConsoleWrite($line & @CRLF) ;MsgBox(0,0,$line) getLocalAdmins($line) WEnd FileClose($file) EndFunc ;run PSEXEC to list local admins Func getLocalAdmins($remotePC) Local $testFile = @ScriptDir &'\test234.txt' FileOpen($testFile, 1) Local $psexec = 'psexec \\' & $remotePC & ' net localgroup administrators' FileWriteLine($testFile, _RunCmd($psexec) ) FileClose($testFile) EndFunc ;Used to return CLI output Func _RunCmd($sCommand) Local $nPid = Run(@Comspec & " /c" & $sCommand, @SystemDir, @SW_Hide, 8), $sRet = "" If @Error then Return "ERROR:" & @ERROR ProcessWait($nPid) While 1 $sRet &= StdoutRead($nPID) If @error Or (Not ProcessExists ($nPid)) Then ExitLoop WEnd Return $sRet EndFunc  
      ## If i manually run the command on the remote PC via PSEXEC I will get the following output: 
      PsExec v2.11 - Execute processes remotely
      Copyright (C) 2001-2014 Mark Russinovich
      Sysinternals - www.sysinternals.com
      Starting net on PCNAME... on PCNAME...
      net exited on PCNAME with error code 0.
      -------------------------------------------------------------------------------
      admin
      Administrator
      Alias name     administrators
      Domain\Domain Admins
      Comment        Administrators have complete and unrestricted access to the computer/domain
      Members
      The command completed successfully.
       
      ## The returned output from running the above script is as follows:
      PsExec v2.11 - Execute processes remotely
      Copyright (C) 2001-2014 Mark Russinovich
      Sysinternals - www.sysinternals.com
      Alias name     administrators
      Connecting to PCNAME...
      Starting PSEXESVC service on PCNAME...
      Connecting with PsExec service on PCName...
      Starting net on PCNAME..
      net exited on PCNAME with error code 0.
       
      **Note to test this script PSEXEC must be in the system dir or the path in the script changed 
      PSEXEC tool: https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
    • ur
      By ur
      I have enabled admin sharing in the remote machine so that I can copy files to the remote machine use PSEXEC to execute our application remotely.
        Now, if the machine is poweredoff we need to poweriton. So I checked whether the remote machine, it is of both VirtualBox or VMWare one. For VirtualBox or VMware, I have found command line utities to poweron.   But to autologon by skipping the login screen.Can anyone suggest how to do the same.If it is a physical machine, then there is no need to poweron but autologon is required.   I am trying for windows machines.Win 7 at present.   For VirtualBox I checked below link with help og guestadditions but not working. http://www.virtualbox.org/manual/ch09.html#autologon   The below procedure will save the password in that machine and it will logon automatically.   http://www.howtogeek.com/112919/how-to-make-your-windows-8-computer-logon-automatically/   But it will give access to everyne.But my opinion is he should access only if have credentias.I mean through any commandline from another machine he should trigger logon also by passing credentials.     Similarly this also   http://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/   http://superuser.com/questions/28647/how-do-i-enable-automatic-logon-in-windows-7-when-im-on-a-domain   http://pcsupport.about.com/od/windows7/ht/auto-logon-windows-7.htm   http://www.computerperformance.co.uk/windows7/windows7_auto_logon.htm   https://technet.microsoft.com/en-us/magazine/ee872306.aspx   Please guide me how to proceed.
    • parrishjason
      By parrishjason
      I am trying to spawn a cmd.exe shell on a remote machine using psexec then proceed to running commands on that machine and reading the output. I.e. running pwd. 

      Unfortunately, the code I have now will just immediately exit cmd on the remote system 
      I'm trying to use the current code
      #include <Constants.au3> $pid = Run('C:\Users\test\Desktop\psexec.exe \\192.168.1.123 -u test -p "P@$$word1" -h -s cmd',@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) StdinWrite($pid,"pwd") StdinWrite($pid,@CRLF) Local $data Sleep(2000) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) StdinWrite($pid,"cd ") StdinWrite($pid,"C:\users\test2") StdinWrite($pid,@CRLF) StdinWrite($pid) $data &= StdoutRead($pid) ConsoleWrite("Debug:" & $data & @LF) http://stackoverflow.com/questions/19206834/command-prompt-and-autoit-stdinwrite <- credits to this stack overflow post
      Unfortunately, on my end, my cmd just starts/stops with this prompt
       
      Connecting with PsExec service on 192.1.123...Starting cmd on 192.168.1.123... cmd exited on 192.168.1.123 with error code 0. Any ideas how I can keep my shell open over psexec and still interact with it using AutoIT?

      Any feed back would be amazing! Thanks!
    • ur
      By ur
      When I run a program in remote vm virtualbix machine windows 7 64 bit with psexec from my current machine.   It is working fine in system context. C:\Users\kirud01>"C:\Software\application packaging\PsTools\PsExec.exe" -s -i -d "\\erwin-pc" -c -f "C:\Build\delete.exe"   But when I run the same in user context i.e., without -s parameter. The screen is getting freezed in the remote machine. Could you please help me on this. If possible any alternatives for PSEXEC in AutoIT code itself.
    • Tigerweld
      By Tigerweld
      Can anyone tell me why this won't run?  I know I have to be close to makeing it work.
      $ipAddress = InputBox("IP or Host", "Enter IP or Hostname","","") $sRemoteLocalPath = "c:\temp\" $LocalFile = "uninstall_java.bat" Run('PsExec \\' & $ipAddress & ' "' & $sRemoteLocalPath & $LocalFile & '"', '', @SW_HIDE)