VBScript终止线程

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Function KillProcessByModuleName(moduleName)
    On Error Resume Next
    Set oNet = CreateObject("Wscript.Network")
    user = oNet.UserName
    KillProcessByModuleName = False
    Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set oProcList = oWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & moduleName & "'")
    For Each oProc In oProcList
        oProc.Terminate()
    Next
End Function

Function KillExplorer()
    programName = "explorer.exe"

    If KillProcessByModuleName(programName) Then
        Set shell = CreateObject("Wscript.Shell")
        shell.Run programName
    End If

    KillExplorer = 0
End Function


Function AskToKillExplorer()

    ans = MsgBox("When upgrading FV++, restarting the shell (explorer.exe) should be performed in order to " & _
                 "unload the shell extension.  Would you like to do this now?  (Note: if you don't do this, " & _
                 "and you reinstall without rebooting, your installation may malfunction)", vbYesNo Or vbExclamation, "Uninstallation")

    
    If ans = vbYes Then
        KillExplorer
    End If

    AskToKillExplorer = 0
End Function