1

I'm working on a VBScript to show a msgbox if a system condition is hit (it's running a loop which sleeps after each iteration).

The issue: I've noted that, when I run the script, it doesn't actually show in the TaskManager (EDIT: in the "Processes" tab) unless it has previously displayed a msgbox (after which point it shows up as "Microsoft ® Windows Based Script Host" as I'd expect).

FYI: I'm searching Task Manager by sorting by name and then looking under "Background processes".

VBScripts being hidden is problematic for a number of reasons:

  • I can't easily kill the process: either during development or to change a constant value
  • I can't know whether the process is running, or how many times. I was just surprised by, like, 20 msgbox's as I had ran the script many times while working on it.
  • it seems generally unsafe as scripts could run without being visible.

Is this normal? Am I missing something? Is there a way to force a wscript process to always show in the Task Manager (EDIT: in the "Processes" tab)?

EDIT: @garbb pointed out that you can see all of the running VBScripts in the "Details" tab. This actually resolves most of my issues. I'm still curious, though: why does the "Processes" tab not list running VBScripts until after they have displayed their first msgbox? They are separate processes, right? This leaves space for malicious scripts to be stealthy (unless the user checks the "Details" tab).

3
  • Check under the "Details" tab for wscript.exe?
    – garbb
    Commented Oct 31, 2021 at 0:00
  • @garbb, yes that does the trick. I'm still curious as to why it's not showing in the "Processes" tab, but this definitely resolves my main issues. Thank you! Commented Oct 31, 2021 at 0:06
  • Microsoft Windows Based Script Host doesn't appear on your Process tab? Commented Dec 20, 2021 at 0:24

1 Answer 1

0

I don't know you or other member here, can get help from this old vbscript to choose and select what vbscript is running and want to kill it.

So for that i named it as :


Wscript_Killer_Selector.vbs

Option Explicit
Dim Title,Copyright,fso,ws,LogFile,temp,PathLogFile,OutPut,Count,strComputer
Copyright = " ["& chr(169) &" Hackoo 2014 ]"
Title = " Processes "& DblQuote("Wscript.exe") &" Running"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject( "Wscript.Shell" )
LogFile="Process_WScript.txt"
temp = ws.ExpandEnvironmentStrings("%temp%")
PathLogFile = temp & "\" & LogFile
Set OutPut = fso.CreateTextFile(temp & "\" & LogFile,1)
Count = 0 
strComputer = "."
Call Find("wscript.exe")
Call Explorer(PathLogFile)
'----------------------------------------------------------------------------------------------
Function Explorer(File)
    Dim ws
    Set ws = CreateObject("wscript.shell")
    ws.run "Explorer "& File & "\",1,True
end Function
'----------------------------------------------------------------------------------------------
Sub Find(MyProcess)
    Dim colItems,objItem,Process,Question
    Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
    & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
    For Each objItem in colItems
        Count= Count + 1
        'Extracting the path of the script from the command line
        Process = Trim(Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2))
        Process = Replace(Process,chr(34),"")
        Question = MsgBox ("Do you want to stop this script : "& DblQuote(Process) &" ?" ,VBYesNO+VbQuestion,Title+Copyright)
        If Question = VbYes then
            objItem.Terminate(0)' Kill this process
            OutPut.WriteLine DblQuote(Process)
        else
            Count= Count - 1 'decrement the counter by -1
        End if
    Next
OutPut.WriteLine String(100,"-")
OutPut.WriteLine count & Title & " have been killed !"
End Sub
'----------------------------------------------------------------------------------------------
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'----------------------------------------------------------------------------------------------
2
  • Thanks for this. Personally, I feel comfortable enough with Task Manager to kill my scripts through it, now that I know to go to the "Details" tab to see my running VBScript processes. Commented Nov 1, 2021 at 20:42
  • @JonathanHeard You are free to choose what method do you prefer, but i just i wonder if did you tried this vbscript on your side or not yet ? and tell me if it works or not because this script is old and i don't know if this still works or not ? Thank you !
    – Hackoo
    Commented Nov 2, 2021 at 8:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .