none
VBScript Error: Expected statement RRS feed

  • Question

  • Error Message says 

    Line: 21

    Char: 1

    Error: expected statement

    1. result = MsgBox("Are you sure you wanna update your Windows 10?",4+64,"Windows 10 Update") 
    2. Select Case result
    3. Case vbYes
    4. MsgBox"Installing Virus",0+16,"Who would install a windows update?"
    5. Dim objShell
    6. Set objShell = Wscript.CreateObject("WScript.Shell")
    7. objShell.Run "error2.vbs"
    8. Case vbNo
    9.  cats = MsgBox ("Oh no you don't! Youll HAVE to install the new windows!",3+16,"Nope!") 
    10. Select Case cats
    11. Case vbCancel
    12. MsgBox"You cant cancel windows updates!"
    13. End select
    14. Set objShell = Wscript.CreateObject("WScript.Shell")
    15. objShell.Run "WindowsForce.vbs"
    16. Case vbNo
    17. MsgBox "Why not? Plus, we force updates."
    18. Set objShell = Wscript.CreateObject("WScript.Shell")
    19. objShell.Run "WindowsForce.vbs"
    20. End select
    21. Case vbYes
    22. MsgBox "Thank you for complying."
    23. End select
    24. Set objShell = Wscript.CreateObject("WScript.Shell")
    25. objShell.Run "WindowsForce.vbs"
    26. End select
    27. End select

    I bet my scripting is so messed up, im new to vbs, and i don't know what the problem is.

    Can anyone help me please?

    • Moved by Bill_Stewart Tuesday, November 7, 2017 9:06 PM This is not "teach me programming basics from groud zero" forum
    Sunday, September 3, 2017 2:02 AM

All replies

  • If you correctly format your code and post it correctly you would very quickly see your error.

    Your code after a failed attempt to figure it out.

    result = MsgBox("Are you sure you wanna update your Windows 10?",4+64,"Windows 10 Update") 
    Select Case result
    	Case vbYes
    		MsgBox"Installing Virus",0+16,"Who would install a windows update?"
    		Dim objShell
    		Set objShell = Wscript.CreateObject("WScript.Shell")
    		objShell.Run "error2.vbs"
    	Case vbNo
    		cats = MsgBox ("Oh no you don't! Youll HAVE to install the new windows!",3+16,"Nope!") 
    		Select Case cats
    			Case vbCancel
    			MsgBox"You cant cancel windows updates!"
    		End Select
    
    		Set objShell = Wscript.CreateObject("WScript.Shell")
    		objShell.Run "WindowsForce.vbs"
    	Case vbNo
    		MsgBox "Why not? Plus, we force updates."
    		Set objShell = Wscript.CreateObject("WScript.Shell")
    		objShell.Run "WindowsForce.vbs"
    End Select
    
    	Case vbYes
    		MsgBox "Thank you for complying."
    End select
    		Set objShell = Wscript.CreateObject("WScript.Shell")
    		objShell.Run "WindowsForce.vbs"
    End Select
    End select
    

    You have blindly copied and pasted many things together without any understanding of what you are doing.\

    The above makes no sense.  Since you do not know how to script and since VBScript is obsolete you should be learning PowerShell.  Don't waste time on VBScript.

    Look up the VBScript syntax for "Select" to learn how to use it.


    \_(ツ)_/

    Sunday, September 3, 2017 2:19 AM
  • Yea, i suck. So should i just get into Powershell straight away or?
    Sunday, September 3, 2017 7:09 AM
  • I just stumbled upon VBscript, and all i want to do is make branching message boxes, i know ill have to learn, this project was a mish mash of stuff, not knowing the syntax... But i can still use and ask about VBScipt in the forums, right? :|

    Plus obsolete for personal use?

    • Edited by Zvirgzds Sunday, September 3, 2017 8:07 AM
    Sunday, September 3, 2017 7:40 AM
  • You are not asking a question.  You are just saying you have some syntax error.  Before you can ask an intelligent question you need to learn the syntax.

    As I noted.  Don't waste time learning an obsolete system.  Start by getting a book or a tutorial on PowerShell and learn the syntax.  Learn the basics of programming.  You cannot learn by copying and pasting code you do not understand.

    Here is a place to start: https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276

    There are almost no tutorials or documents about VBS left.  There are some but you will have to search. Don't wast the time.

    These technical forums are for answering questions asked by techs and others who are using scripts.  They are not here to teach scripting.  If you have a specific question we can answer it but without any basic knowledge of programming or scripting it will be hard for you to ask a question.

    Learn what "syntax" is.  All scripts have a syntax and will have errors caused by lack of proper syntax.  Learn to look up language syntax to validate your usage.

    Here is one of the few remaining sources of VBS information.  There is more but it is disappearing fast.

    http://vbsedit.com/html/5ce74817-31a0-4248-a7d7-2d30b728d415.asp

     


    \_(ツ)_/

    Sunday, September 3, 2017 8:15 AM