8

What I have tried and didn't work:

  1. I opened cmd.exe
  2. Typed "cd\" >> without quotes
  3. Pressed Enter
  4. Typed "cd C:\Program Files (x86)\Jenkins"
  5. Pressed Enter
  6. Typed "jenkins.exe start"
  7. Pressed Enter

I have also used the sleep command after every type, just to make sure that 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}")

I got the answer:

ControlSend("Administrator: C:\Windows\system32\cmd.exe", "", "", "cd C:\Program Files (x86)\Jenkins")

I needed to remove "Edit" , as cmd is not an editable window.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
paul
  • 4,333
  • 16
  • 71
  • 144

4 Answers4

7

Start your program directly:

RunWait(@ComSpec & " /c jenkins.exe start", "C:\Program Files (x86)\Jenkins")
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Obi
  • 81
  • 1
1

Use &

Exp :

$CMD = 'cd %tmp% & md 1 & md 2 & cd %tmp%/1 & md 3 4 & md "5 6" &'
RunWait(@ComSpec & " /c " & $CMD )
0
Run("C:\WINDOWS\system32\cmd.exe")
WinWaitActive("C:\WINDOWS\system32\cmd.exe")
send('cd C:\Program Files (x86)\' & "{ENTER}")
Andreas
  • 5,393
  • 9
  • 44
  • 53
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}")
Gloria Rampur
  • 353
  • 3
  • 12