7

我尝试过但没有奏效的方法:

  1. 我打开了cmd.exe
  2. 键入 "cd\" >> 不带引号
  3. 按下Enter
  4. 键入“cd C:\Program Files (x86)\Jenkins”
  5. 按下Enter
  6. 键入“jenkins.exe 启动”
  7. 按下Enter

我还在sleep每种类型之后都使用了该命令,只是为了确保它不会因为执行速度快而跳过。

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

我得到了答案:

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

我需要删除 "Edit" ,因为 cmd 不是可编辑的窗口。

4

4 回答 4

6

直接启动你的程序:

RunWait(@ComSpec & " /c jenkins.exe start", "C:\Program Files (x86)\Jenkins")
于 2013-06-07T16:14:14.710 回答
1

利用 &

经验:

$CMD = 'cd %tmp% & md 1 & md 2 & cd %tmp%/1 & md 3 4 & md "5 6" &'
RunWait(@ComSpec & " /c " & $CMD )
于 2015-10-02T02:41:39.690 回答
0
Run("C:\WINDOWS\system32\cmd.exe")
WinWaitActive("C:\WINDOWS\system32\cmd.exe")
send('cd C:\Program Files (x86)\' & "{ENTER}")
于 2013-06-10T06:42:59.983 回答
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}")
于 2016-06-13T11:55:54.787 回答