Jump to content
FMS

Commandline function

Recommended Posts

FMS

Hello,

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)
   Run("C:\WINDOWS\system32\cmd.exe")
   WinWaitActive("C:\WINDOWS\system32\cmd.exe")
   Sleep(50)
   send("cd\" & "{ENTER}")
   Sleep(50)
   send("cd Tools" & "{ENTER}")
   Sleep(50)
   send("pskill \\" & $$xip & " -u username -p pass /accepteula app.exe" & "{ENTER}")
EndFunc

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
Skitty

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
FMS

@Skitty

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
rudi

Hi.

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
VIP

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

 


Regards,
 

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

    • ternal
      By ternal
      Hi,
      The FAQ proposed as a solution to keys getting stuck  to do this command
      ControlSend("", "", "", "text", 0) However this sends "text" to the last active control if I am not mistaken.I have tried this with
      controlsend("", "", "", "{altup}{shiftup}{ctrlup}", 0) This is already a lot better but still fails 1/10
      I cannot allow the script to send "text" to the last active control, and its a bit silly to let it send to somewhere where its harmless no?
      Are there any other methods of unstucking keys?
    • Fortitude
      By Fortitude
      Hello!
      I have made a program, that opens a folder, and then store the path ("C:\programFiles\etc") in a variable.
      Then i need to open the command panel as administrator, and write  in the stored path, and some other text.

      Can i somehow instantly copypaste the text i needed, instead of writing in the command panel with the Send commands?
       
      #RequireAdmin #include <MsgBoxConstants.au3> Global Const $sMessage = "Select a folder" ; Display an open dialog to select a file. Global $sFileSelectFolder = FileSelectFolder($sMessage, "") If @error Then MsgBox($MB_SYSTEMMODAL, "", "Nem választottál ki mappát!") Exit EndIf Global $Tiff_path = $sFileSelectFolder & "\TiffChecker_2_32" FileCopy( "C:\TiffChecker_2_32.exe" , $sFileSelectFolder) $CMD = $Tiff_path & " " & $sFileSelectFolder & " /s/d" Run("C:\WINDOWS\system32\cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send($CMD) Sleep(1000) Send("{ENTER}") sleep(1000) MsgBox(0,"Press OK", "Press OK to continue") FileCopy("C:\Tiffchecker.txt", $sFileSelectFolder) Also, how do i close the command panel, when the program is finished? (usually its under 1 second, so after the send i just put a Sleep function there)
    • Docfxit
      By Docfxit
      I would like to know if there is a way to make the send cmd send characters when using
      Graphical AutoIt Debugger By Stumpii,
      If Not WinActive("Setup - UltraVNC","Setup is preparing to install") Then WinActivate("Setup - UltraVNC","Setup is preparing to install") WinWaitActive("Setup - UltraVNC","Setup is preparing to install") Send("{ALTDOWN}f{ALTUP}") ;Finish The debugger when using step mode will execute the Send cmd line but the window doesn't receive the input.
      Thanks,
      Docfxit
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      I'm trying to send SHIFTDOWN, to keep the Shift key pressed until I close the program or releases the key.
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key manually and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down Agin", "Shift key is pressed again, now type something: ") In the above program sequence,
      1. Send SHIFTDOWN from program, Works as we type in the text are in Capital letters
      2. Manually presses and releases the SHIFT button. SHIFT key is released as when we type, text is in small letters only.
      3. Again send SHIFTDOWN from program, but not working. When we type the letters are in small letters.
       
      If we send a SHIFTUP  before  sending the SHIFTDOWN again, then it is working correctly and the text appears in capital letters only. Can any one explain why this happens?
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTUP}") sleep(100) Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is pressed, now type something: ")  
      Thank you.
    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
×