Jump to content

Commandline function

Recommended Posts



I've made a GUI that can send multiple commands.
The way I'm doing this at the moment is whit "send" commands.
also first go to the right directory where the "to be used" program sits
And send from there the commandline argument whit parameters.

Here is a example of the way I'm using it now:

Func restart_app($xip)
   send("cd\" & "{ENTER}")
   send("cd Tools" & "{ENTER}")
   send("pskill \\" & $$xip & " -u username -p pass /accepteula app.exe" & "{ENTER}")

This way is working and I got no problems whit this.
Also I realy think there is a mush better and way to do the same and maybe a little bit less error free :)
(even better if this is hidden for the user :))
On this forum I could not find anything related to this subject (or I was not looking in the right direction) and hope somebody knows a better way :)

Is there a way where u can send the arguments and parameters directly in 1 line to the commandpromt whitout using "send" to commandprompt?

Thanks in advanced

ps: I also tried :

ShellExecute("pskill", "\\" & $xip & " -u username -p pass /accepteula app.exe")

But din't work

Edited by FMS

as finishing touch god created the dutch

Share this post

Link to post
Share on other sites

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post

Link to post
Share on other sites


Thanks , this was indeed what i was looking for.
For futher referense :

RunWait(@ComSpec & " /k " & "pskill \\" & $xip & " -u username -p pass /accepteula posclient.exe"  , "C:\tools",@SW_HIDE )

/k is for debugging....

as finishing touch god created the dutch

Share this post

Link to post
Share on other sites


PSKILL.EXE does *NOT* need a @comspec shell to execute,

And " /k " instead of " /c " just doesn't exit the comspec shell after the called program terminated.


Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

Good luck:

Func _PsKill($AppName, $IP = "", $Uname = "", $PassWord = "")
    If StringStripWS($AppName, 8) = "" Then Return SetError(1, 0, 0)
    Local $sCommand, $PsKillEXE = @ScriptDir & "\pskill.exe"
    If $IP <> "" Then $sCommand &= " \\" & $IP
    If $Uname <> "" Then $sCommand &= ' -u ' & $Uname & ''
    If $PassWord <> "" Then $sCommand &= ' -p "' & $PassWord & '"'
    $sCommand &= " /accepteula " & $AppName
;~  RunWait('"' & $PsKillEXE & '" ' & $sCommand, @ScriptDir, @SW_HIDE)
    ShellExecute($PsKillEXE, $sCommand, @ScriptDir, "", @SW_HIDE)
EndFunc   ;==>_PsKill



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

  • Similar Content

    • Kevin Finnegan
      By Kevin Finnegan
      Hi all,
      Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well!
      I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often.
      Here is the working version:
      ; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?

    • AndreyS
      By AndreyS
      Dear developers and creators of the language, please explain to me why when pressing the combination Crtl + Shift + C from the 5th or the 10th time "sticks / sinks" Ctrl or Shift? And then you need to press Ctrl or Shift again to reset their triggering. I only need to use hot keys like in the example!
      The code is a small example. Its essence is that when a user in the editor selects any number and presses a combination, then it increases by 1. 
      Dim $x HotKeySet("+^c","Calc") While 1 Sleep(10000) WEnd Func Calc() Send("^c") Sleep(50) $x=ClipGet()+1 ClipPut($x) Send("^v") EndFunc I thought that in my program some kind of glitch was searching for a reason for a long time. And it turned out that apparently somehow the work of some functions used in the example is not compatible. 
      Tell me, please, what is the problem?
    • ur
      By ur
      If you observe in below code.
      Func _WinWaitActivate($title,$text,$timeout=$time_out) Logging("Waiting for "&$title&":"&$text) $dHandle = WinWait($title,$text,$timeout) if not ($dHandle = 0) then If Not WinActive($title,$text) Then WinActivate($title,$text) WinWaitActive($title,$text,$timeout) Else Logging("Timeout occured while waiting for the window...") Exit EndIf EndFunc WinActivate("Untitled - Notepad") $p = "Notallowed1!!" Send("{ENTER}{ENTER}{ENTER}{ENTER}"& $p &"{ENTER}create{SPACE}database{SPACE}"& $p &";{ENTER}") In the notepad if you observe, ! is missing in the text got.
      Is there way to get that also printed.
    • rawkhopper
      By rawkhopper
      Hello everyone,
      I have a script that is automating a piece of sluggish software.  I want to automate it with a bit of caution and I am not sure the best way to do it.  ControlSend works great most of the time.  If I have it enter 10 into a text box every once in a while it will enter 1 or 11 and then hit enter.
      To overcome this I use MouseClick to select the text I just entered and then see if it matches the string it was supposed to put in before it hits enter.  This seems to work but what I love about ControlSend is there is less room for human interaction messing it up.  
      Yes I could block input but I prefer not to do that (permissions).
      Is there a better way of doing this?  Any Help would be much appreciated.
      Anyway here is the snippet of the script in question:
      Func KVSend () WinActivate ( "Window", "" ) Local $WindowPos = WinGetPos("Window", "") If $kV < 30 Then WinActivate ( "Window", "" ) ControlClick ("Window", "", 1001) ;Click in Accel Voltage box Sleep (100) ControlSend ("Window", "", 1001, $kV) ; \ kV Sleep (100) MouseMove($WindowPos[0]+130,$WindowPos[1]+75,1) MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) Send ("^c") Local $clip = ClipGet () If $clip = $kV Then ControlSend ("Window", "", 1001, "{ENTER}") ;Hit ENTER if value is correct Sleep (100) ControlClick ("Window", "", 1518) ;Lens Clear Else Send ("{BACKSPACE}") KVSend() ; If value is incorrect try again EndIf EndIf  

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.