3

次のバッチ スクリプトを実行しています。

@echo off
tasklist /nh /fi "Windowtitle eq Export to PDF - DOORS" | find /i "Export to PDF - DOORS" >nul && (
echo PDF is running
) || (
echo PDF is not running
)

これは、ウィンドウが現在アクティブな場合にのみ「PDF が実行中です」と表示されます。おそらく、間違ったコマンド (タスクリスト) を使用しています。開いているウィンドウの完全なリストで見つける方法はありますか?

4

3 に答える 3

4

VBスクリプトで必要なものを手に入れることができました(@ JoshGuzmanのアイデアに感謝します):

Set Word = CreateObject("Word.Application")
Set Tasks = Word.Tasks

For Each Task in Tasks
  If Task.Visible Then
    If Task.name = "Export to PDF - DOORS" Then
      Wscript.Echo "PDF is Running"
    Else 
      Wscript.Echo "PDF is not Running"
    End If
  End If
Next

Word.Quit

wscript myScript.vbs次に、コマンド プロンプトまたはバッチ ファイルからVB スクリプトを呼び出します。

于 2012-09-04T17:57:09.033 に答える
1

cmd.exe の代わりに Microsoft の PowerShell を使用する場合 (古い Windows XP でも動作します。手動でインストールする必要がありました。新しい Windows バージョンではプリインストールされています)、スナップインとしてWASPをインストールし、次にこれを行います:

Select-Window | Format-Table processid,processname,title -AutoSize

AUSFÜHRLICH: Enumerating all windows

ProcessId ProcessName  Title
--------- -----------  -----
     7452 powershell   Windows PowerShell V2 (CTP3)
     2688 chrome       cmd - tasklist show all windows - Stack Overflow - Google Chrome
     2688 chrome       List all open window titles - PowerShellCommunity.org - Windows PowerShell Discussion Forums ...
     3572 TOTALCMD     Total Commander 8.0 - Scrum-Master.de  Inh. Alexander Kriegisch
     4152 eclipse      Java - dummy2/src/de/scrum_master/aop/log4j/Log4jAspect.aj - Eclipse Platform - Java, Scala, ...
     5608 Foxit Reader quick5A4.pdf - Foxit Reader
     2812 TextPad      TextPad - [C:\Dokumente und Einstellungen\Robin\Eigene Dateien\java-src\dummy2\bin\log4j.prop...

ご覧のとおり、両方のクロム ウィンドウが一覧表示されますが、オンボード コマンドGet-Processはプロセスごとに 1 つのウィンドウのみを一覧表示tasklistcmd.exeます。

Get-Process | Where {$_.mainwindowtitle} | Format-Table id,name,mainwindowtitle -AutoSize

  Id Name         MainWindowTitle
  -- ----         ---------------
2688 chrome       cmd - tasklist show all windows - Stack Overflow - Google Chrome
4152 eclipse      Java - dummy2/src/de/scrum_master/aop/log4j/Log4jAspect.aj - Eclipse Platform - Java, Scala, Aspec...
5608 Foxit Reader quick5A4.pdf - Foxit Reader
7452 powershell   Windows PowerShell V2 (CTP3)
2812 TextPad      TextPad - [C:\Dokumente und Einstellungen\Robin\Eigene Dateien\java-src\dummy2\bin\log4j.properties]
3572 TOTALCMD     Total Commander 8.0 - Scrum-Master.de  Inh. Alexander Kriegisch
于 2012-09-01T09:32:48.567 に答える