- 批次檔 (upload.bat)
Set PROJECTDIR="D:\workspace\TestPHP"
path "c:\program files\winscp"
winscp.exe /console /command "option batch abort" "option batch on" "option confirm off" "open sftp://user:password@server" "cd /var/www/html" "put %PROJECTDIR%\*.php" "exit"
actAPP.vbs "google chrome"
主要是上傳是透過winscp,它指令google大神會告訴你詳細,我只用到以上幾個就不說明了;
actAPP.vbs是要叫起chrome的script 如下,有二種寫法不過 tasklist的方式單獨執行actAPP.vbs正常,但是經由批次檔去呼叫就無法取到 tasklist,找不到原因 orz...
actAPP.vbs是要叫起chrome的script 如下,有二種寫法不過 tasklist的方式單獨執行actAPP.vbs正常,但是經由批次檔去呼叫就無法取到 tasklist,找不到原因 orz...
- VBSscript (actAPP.vbs)
Set objShell = CreateObject("Wscript.Shell")
Set objWord = CreateObject("Word.Application")
Set tasks = objWord.Tasks
Set res = WScript.Arguments
Dim app_name
'取得代入的參數(WINDOWSTITLE 視窗標題,工作管理員->應用程式 看到的名稱 )
app_name= "google chrome"
If res.length > 0 then
'MsgBox("test_" + cstr(res.length))
app_name = res(0)
End If
For Each objTask in tasks
strName = LCase(objTask.Name)
If Instr(strName, app_name) Then
WScript.Sleep 500
objShell.AppActivate strName ' 把已開啟的視窗叫到最上層並Focus它
WScript.Sleep 500
objShell.SendKeys "{F5}" ' 送一個重新整理的指令
Exit For
End If
Next
objWord.Quit
VBSscript (actAPP.vbs)原本想用tasklist取得目前執行中的程序,這方法感覺比較正統,不過透過批次檔呼叫就會失敗
Set objShell = CreateObject("Wscript.Shell")
Set res = WScript.Arguments
Dim app_name
'取得代入的參數(IMAGENAME 執行檔名)
app_name= "chrome.exe"
If res.length > 0 then
'MsgBox("test_" + cstr(res.length))
app_name = res(0)
End If
'MsgBox(app_name)
'組 tasklist 指令過濾只取執行中程序
strCommand = "cmd /c tasklist /V /FO ""LIST"" /FI ""IMAGENAME eq " & app_name & """ /FI ""STATUS eq RUNNING"" | sort"
Set objExecObject = objShell.Exec(strCommand) '執行 tasklist
'MsgBox(objExecObject.StdOut.AtEndOfStream)
' 解析 tasklist 輸出的 "LIST" 資料
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadLine()
'MsgBox(strText)
If Instr(strText, "PID") Then
a=Split(strText, ":") ' 取得符合的 PID
WScript.Sleep 500
objShell.AppActivate a(1) ' 把已開啟的視窗叫到最上層並Focus它
WScript.Sleep 500
objShell.SendKeys "{F5}" ' 送一個重新整理的指令
Exit Do
End if
Loop
沒有留言:
張貼留言