Sub DeleteFolder(folderPath)
    On Error Resume Next
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")

    If fso.FolderExists(folderPath) Then
        fso.DeleteFolder folderPath, True
        If fso.FolderExists(folderPath) Then
            WScript.Sleep 1000
            CreateObject("WScript.Shell").Run "cmd /c rd /s /q " & Chr(34) & folderPath & Chr(34), 0, True
        End If
    End If

    Set fso = Nothing
End Sub

Dim processName, deletePath, programPath

If WScript.Arguments.Count >= 3 Then
    processName = WScript.Arguments(0)
    deletePath = WScript.Arguments(1)
    programPath = WScript.Arguments(2)

    ' 终止进程
    CreateObject("WScript.Shell").Run "taskkill /f /im " & processName, 0, True
    WScript.Sleep 1000

    ' 只有删除路径非空时才执行删除
    If deletePath <> "" Then
        DeleteFolder deletePath
        WScript.Sleep 1000
    End If

    ' 启动程序
    If programPath <> "" Then
        CreateObject("WScript.Shell").Run Chr(34) & programPath & Chr(34), 1, False
    End If
End If
