r/vbscript • u/njgunrights • Nov 13 '21
How do I exit or terminate a script?
So I have this code that works great except it does not exit and replicates itself until it crashes my computer. I tried using the "Exit" command by using X.Exit at the end of my code but computer gives me an error. What are some of the ways I can get a script to stop running after it is done it's task? I assume there are multiple ways to do this. Here is the code. It is intended to open Firefox then type hello world in the address bar of Firefox which it does do well.
Set x = CreateObject("WScript.Shell")
x.Run """C:\Program Files\Mozilla Firefox\firefox.exe"""
Set objShell = Nothing
WScript.Sleep(100)
x.SendKeys "~"
x.SendKeys "Hello World!"
2
u/hackoofr Nov 13 '21 edited Nov 13 '21
To quit the vbscript you must add this :
NB : Your code shown above is not well formatted and can be truncated or incomplete.
Please try to edit it and format it correctly
Convert2MarkDown.bat to convert and format code into MarkDown Mode and post it easily on Reddit
2
u/hackoofr Nov 14 '21 edited Nov 14 '21
Give a try for this code :