Super User Asked by Geco Mynx on December 23, 2021
I have a .vbs-Script that is running in the background endlessly. This script does not have any way for the user to interact with it; a regular user won’t even notice something is running in the background. Now I need to be able to end this Script at any time.
So, now I’m searching for the easiest way to be able to cancel this .vbs-Script without using the Task Manager, other Tools or additional Scripts and without typing something like this to PowerShell or the Command Prompt:
PowerShell: Stop-Process -Name wscript
Command Prompt: Taskkill /IM wscript
I tried running a .cmd-Script that simply runs the .vbs-Script. I hoped I’d be able to end the .vbs-Script alongside with the .cmd either by pressing CTRL+C or by closing the Command Prompt, but I’ve tested it, and it didn’t work this way.
So I googled a little bit and found out it’s possible to create a visible Tray-Icon for a running .vbs-Script that would allow right-clicking it to close it.
But I can’t get it to work. Following you can see the code, I tried.
The first three lines are for the Tray-Icon, line four to nine is the actual script that is running in the background:
Public Declare Function Shell_NotifyIcon Lib "shell32" _
Alias "Caffeinate" _
(ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim objResult
Set objShell = WScript.CreateObject("WScript.Shell")
Do While True
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
Wscript.Sleep (6000)
Loop
Does someone know how to make use of a System Tray-Icon for a vbs.Script?
Alternatively, any other “easy-to-use” way to cancel a .vbs-Script like that would be super nice.
Kind regards,
Kevin
@ZevSpitz Your Tip is working fine, thanks again. :D
This is the way I'm doing it now:
Answered by Geco Mynx on December 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP