是不知道重启哪个么?
可以先把你的这些bat代码做些标记,例如给bat每个程序都加上不同标题,再然后用vbs去识别这些标题,从而区分哪个是你需要重启的程序
追问重启某个bat时,先要结束对应的后台正在运行的bat,而后台每个bat的脚本,进程名都是cmd.exe,所以问题是如何在后台运行的bat中做识别,能否自定义进程名而不是统一的cmd.exe呢
追答dim count,program_list(),wsc
set wsc=createobject("wscript.shell")
program_run("cmd") '隐藏运行. 这条指令每执行一次都会记下一个标识用program_list来获取,例如运行3次后标识为0,1,2
program_run("cmd")
program_run("cmd")
'这些标识代表进程的pid值
taskkill program_list(0) '根据pid值结束指定进程
taskkill program_list(1)
taskkill program_list(2)
set wsc=nothing
function tasklist(byval name)
dim list
set wmi=getobject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").execquery("select * from win32_process")
for each list In wmi
if instr(list.name,"cmd")>0 then tasklist=list.processid
next
wsc.run "taskkill /f /im wmiprvse.exe",0
set wmi=nothing
end function
function program_run(byval file)
wsc.run file,0
program_run=tasklist(file)
redim preserve program_list(count)
program_list(count)=program_run
count=count+1
end function
function taskkill(byval name)
wsc.run "taskkill /pid "&name,0
end function