我从网上搜索了一些简单功能的代码,把它们考到我的电脑里 .vbs文件里,直接双击运行,
但总会报一些奇怪的错误。连这句”Dim i As Integer ” 也会报 语句未正常结束。有没有高手给指导一下,这是为什么?
我之前并没有接受过系统的学习,求科普一下
最下面附图片
以下这行代码会报缺少括号
Private Sub Command1_Click()
If CheckExeIsRun("T5CAPP.exe") Then
MsgBox "存在"
Else
MsgBox "不存在"
End If
End Sub
'检查进程是否运行,exeName 参数是要检查的进程 exe 名字,比如 VB6.EXE
Private Function CheckExeIsRun(exeName As String) As Boolean
On Error GoTo Err
Dim WMI
Dim Obj
Dim Objs
CheckExeIsRun = False
Set WMI = GetObject("WinMgmts:")
Set Objs = WMI.InstancesOf("Win32_Process")
For Each Obj In Objs
If (InStr(UCase(exeName), UCase(Obj.Description)) <> 0) Then
CheckExeIsRun = True
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
End If
Next
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
Err:
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
End Function