logFile = "D:\\python\\start_python.log"

Sub writeLog(msg)
    Dim fso, logStream, mode
    Set fso = CreateObject("Scripting.FileSystemObject")

    ' 不存在就覆盖创建(2)，存在就追加(8)
    If fso.FileExists(logFile) Then
        mode = 8
    Else
        mode = 2
    End If

    Set logStream = fso.OpenTextFile(logFile, mode, True, -1) ' -1 UTF-16
    logStream.WriteLine Now & "  " & msg
    logStream.Close
End Sub

Function isProcessExists(strExeName)
    On Error Resume Next
    strComputer = "."
    Set wbemServices = GetObject("winmgmts:\\" & strComputer)
    Set wbemObjectSet = wbemServices.InstancesOf("Win32_Process")
    isProcessExists = False

    For Each wbemObject In wbemObjectSet
        namedata = wbemObject.Name
        exeFileName = strExeName & ".exe"
        If exeFileName = namedata Then
            isProcessExists = True
            Exit Function  ' 找到后直接退出
        End If
    Next
End Function

Call startPythonScript("python", "D:\python\alipay_account_order.py")

Function startPythonScript(pyProcName, scriptPath)
    writeLog "检查进程: " & pyProcName
    isRunning = isProcessExists(pyProcName)

    If isRunning = False Then
        writeLog "NO python 未发现 python，准备启动脚本 start ，: " & scriptPath
        runPythonScript(scriptPath)
    Else
        writeLog "is python True 已存在，跳过启动"
    End If
End Function

Function runPythonScript(scriptPath)
    On Error Resume Next
    Dim objShell
    Set objShell = CreateObject("Wscript.Shell")

    cmd = "python """ & scriptPath & """"
    writeLog "python alipay_account_order .py 执行命令 " & cmd

    objShell.Run cmd, 0

    If Err.Number = 0 Then
        writeLog "启动 start"
    Else
        writeLog "err 报错: " & Err.Description
    End If
End Function