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}")
1
  • Do not include solution to question please (post a separate answer instead). Commented Jul 19, 2024 at 13:39

4 Answers 4

7

Start your program directly:

RunWait(@ComSpec & " /c jenkins.exe start", "C:\Program Files (x86)\Jenkins")
Sign up to request clarification or add additional context in comments.

Comments

1

Use &

Exp :

$CMD = 'cd %tmp% & md 1 & md 2 & cd %tmp%/1 & md 3 4 & md "5 6" &'
RunWait(@ComSpec & " /c " & $CMD )

Comments

0
Run("C:\WINDOWS\system32\cmd.exe")
WinWaitActive("C:\WINDOWS\system32\cmd.exe")
send('cd C:\Program Files (x86)\' & "{ENTER}")

Comments

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}")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.