本文介绍了如何停止在 Windows 中运行的 vb 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows 7

I'm using windows 7

我编写了一个脚本来检查我的笔记本电脑是使用电池还是交流电运行.我在谷歌上搜索并成功了.

I wrote a script to check whether My Laptop is running in Battery or AC current.I googled it and succedded in that.

dim a
a=1
Do While a=1
If IsLaptop( "." ) Then
   ' WScript.Echo "Laptop"
Else
   ' WScript.Echo "Desktop or server"
End If
Loop

Function IsLaptop( myComputer )
    On Error Resume Next
    Set objWMIService = GetObject( "winmgmts://" & myComputer & "/root/cimv2" )
    Set colItems = objWMIService.ExecQuery( "Select * from Win32_Battery", , 48 )
    IsLaptop = False
    For Each objItem in colItems
        if objItem.BatteryStatus=2 and objItem.EstimatedChargeRemaining=98 then
             WScript.Echo "Remove Ac Adapter Immediately"
        elseif objItem.BatteryStatus=1 and objItem.EstimatedChargeRemaining=10 then
             WScript.Echo "Pluggin to charger immediately"
        end if
    Next
    If Err Then Err.Clear
    On Error Goto 0
End Function

但我现在的问题是.如果我想手动终止,这个脚本一直在运行脚本如何停止.

But my problem now is. This script is ever running script how to stop if i wish to terminate manually.

有什么办法可以找到这个进程并在windows中停止吗?

Is there any way i go and find this process and stop in windows?

推荐答案

我至少能想到两种不同的方法:

I can think of at least 2 different ways:

  1. 使用任务管理器 (Ctrl-Shift-Esc),选择进程选项卡,查找进程名称 cscript.exe 或 wscript.exe 并使用结束进程.

  1. using Task Manager (Ctrl-Shift-Esc), select the process tab, look for a process name cscript.exe or wscript.exe and use End Process.

您可以从命令行使用 taskkill/fi "imagename eq cscript.exe"(根据需要更改为 wscript.exe)

From the command line you could use taskkill /fi "imagename eq cscript.exe" (change to wscript.exe as needed)

另一种方法是使用脚本和 WMI.这里有一些提示:寻找 Win32_Process 类和 Terminate 方法.

Another way is using scripting and WMI. Here are some hints: look for the Win32_Process class and the Terminate method.

这篇关于如何停止在 Windows 中运行的 vb 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 13:30