VB判断EXE文件是否打开。
试了好多种,这个方法蛮好用的。有更好的,希望大家多多指教。
Dim ProNo As Integer, ProStr As String ProNo = IsRunning("SSS.exe") If ProNo = 0 Then Shell App.path & "\SSS.exe '" & strusername & "', PDAOvenInBatch", vbNormalFocus ' '" & strusername & "', PDAOvenInBatch End If '方法 Function IsRunning(ByVal process As String) As Integer Dim OBJWMIService, colProcesses, colProcesse As Object Set OBJWMIService = GetObject("winmgmts:") Set colProcesses = OBJWMIService.ExecQuery("Select * From Win32_Process Where Name='" & process & "'") IsRunning = colProcesses.count 'For Each colProcesse In colProcesses ' MsgBox colProcesse.ExecutablePath ' 进程路径 'Next Set colProcesses = Nothing: Set OBJWMIService = Nothing End Function