How do I issue commands to Windows comand prompt using AutoIt?
Asked Answered
H

4

8

How do I issue commands to Windows comand prompt using AutoIt? What didn't work (I used Sleep() to make sure it is not skipping because of fast execution):

;Run application
Run("cmd.exe")

;Wait for cmd to be opened
WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 15)

;Write some commands on cmd
ControlSend("Administrator: C:\Windows\system32\cmd.exe", "", "Edit1", "cd\")
Sleep(10000)
Send("{Enter}")
Sleep(10000)
ControlSend("Administrator: C:\Windows\system32\cmd.exe", "", "Edit1", "cd C:\Program Files (x86)\Jenkins")
Sleep(10000)
Send("{Enter}")
ControlSend("Administrator: C:\Windows\system32\cmd.exe", "", "Edit1", "jenkins.exe start")
Sleep(10000)
Send("{Enter}")
Heterophyte answered 7/6, 2013 at 8:32 Comment(1)
Do not include solution to question please (post a separate answer instead).Arapaho
S
7

Start your program directly:

RunWait(@ComSpec & " /c jenkins.exe start", "C:\Program Files (x86)\Jenkins")
Sideboard answered 7/6, 2013 at 16:14 Comment(0)
F
1

Use &

Exp :

$CMD = 'cd %tmp% & md 1 & md 2 & cd %tmp%/1 & md 3 4 & md "5 6" &'
RunWait(@ComSpec & " /c " & $CMD )
Fungal answered 2/10, 2015 at 2:41 Comment(0)
G
0
Run("C:\WINDOWS\system32\cmd.exe")
WinWaitActive("C:\WINDOWS\system32\cmd.exe")
send('cd C:\Program Files (x86)\' & "{ENTER}")
Goodard answered 10/6, 2013 at 6:42 Comment(0)
P
0
;Run application
Run("cmd.exe")

;Wait for CMD to be opened
WinWaitActive("Administrator: C:\Windows\system32\cmd.exe", "", 1)
Send('C:' & "{ENTER}")
Send('cd Program Files (x86)' & "{ENTER}")
Send('cd TestAPP' & "{ENTER}")
Send('start testApp.exe' & "{ENTER}")
Proceleusmatic answered 13/6, 2016 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.