用vbscript [duplicate]杀死指定的可执行路径

问题描述 投票:-1回答:1
On Error Resume Next
Dim fso,oShell,file
Set fso = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
oShell.Run "Taskkill /F /IM mysqld.exe",0,True  

file = "C:\xampp\mysql\bin\mysqld.exe"
If fso.FileExists(file) Then
    fso.DeleteFile file
End If
Set oShell = Nothing 
Set fso = Nothing

我尝试使用以下cmd从指定目录中杀死mysqld.exeoShell.run“ WMIC过程在哪里” ExecutablePath之类的'C:\ xampp \ mysql \ bin \ mysqld.exe'“删除但出现错误,甚至在cmd.exe上运行wmic cmd也会出现错误。在其他目录中运行mysqld.exe的进程有多个,如何才能从指定路径中杀死并删除一个进程?

batch-file cmd vbscript wmic
1个回答
-1
投票

打字命令或模拟打字命令未编程。

可从命令行界面获得这些对象的帮助。

wmic path Win32_Process get /?

wmic path Win32_Process call /?

并且如果对象具有可写属性

wmic path Win32_Process set /?

任何命令都可以做的程序也可以。

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")

For Each objItem in colItems
    'msgbox objItem.name & " " & objItem.CommandLine
    If LCase(objItem.name) = "notepad.exe" then 
        If Msgbox("Close Notepad", 33, "Program Closer") = 1 then
            objItem.terminate
        End If
    End If
Next
© www.soinside.com 2019 - 2024. All rights reserved.