吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 148|回复: 3
收起左侧

[资源求助] 给2个vbs的代码合并后弄个判断选择运行其中1个代码

[复制链接]
manljd 发表于 2024-11-1 01:43
50吾爱币
把他两合在一个*.vbs里面,每次运行后自动判断有无进程alist.exe,没有alist.exe进程运行代码1,有alist.exe进程运行代码2,谢谢了。

https://kdocs.cn/l/cujpMkDLcEwb

最佳答案

查看完整内容

[mw_shl_code=asm,true]Dim ws, objWMIService, colProcessList, processFound Set ws = CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'alist.exe'") processFound = False For Each process In colProcessList processFound = True Exit For Next If processFound ...

免费评分

参与人数 1热心值 +1 收起 理由
boyljd + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

秋名山 发表于 2024-11-1 01:43
[Asm] 纯文本查看 复制代码
Dim ws, objWMIService, colProcessList, processFound

Set ws = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'alist.exe'")

processFound = False
For Each process In colProcessList
    processFound = True
    Exit For
Next

If processFound Then
    ' alist.exe is running, execute code block 2
    ws.run "cmd /c d: & cd D:\WangPan & alist server", vbhide
    Set objShell = CreateObject("WScript.Shell")
    strCommand = "net start RaiDrive.Service"
    objShell.Run strCommand, 0, True
    WScript.Sleep(10000)
    ws.run """C:\Program Files\OpenBoxLab\RaiDrive\RaiDrive.exe"""
    WScript.Sleep(5000)
    ws.AppActivate "RaiDrive"
    Do
        ws.SendKeys "%+{F4}"
        WScript.Sleep(1000)
    Loop
Else
    ' alist.exe is not running, execute code block 1
    ws.run "taskkill /f /im alist.exe", 0
    ws.run "taskkill /f /im RaiDrive.exe", 0
    ws.run "taskkill /f /im RaiDrive.Service.x64.exe", 0
    ws.run "taskkill /f /im RaiDrive.BrowserSubprocess.exe", 0
    MsgBox "Ailst已卸载"
End If

WScript.Quit

问下GPT就好了

免费评分

参与人数 1吾爱币 +1 收起 理由
manljd + 1 不成功,帮忙再看看

查看全部评分

 楼主| manljd 发表于 2024-11-1 20:09
没有alist.exe进程运行:启动.vbs,有alist.exe进程运行:关闭.vbs  
大家帮忙看看  非常感谢
 楼主| manljd 发表于 2024-11-1 20:15
秋名山 发表于 2024-11-1 04:19
[mw_shl_code=asm,true]Dim ws, objWMIService, colProcessList, processFound

Set ws = CreateObject(" ...

好像整反了,我连交换位置都不会  交换2代码位置后报错
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 01:58

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表