none
VBScript future RRS feed

  • Question

  • We are considering VBScript as scripting language in one of our desktop application, we would like to know what is the future of VBScript using WSH? will it be supported in future generations of Windows?.
    • Edited by MeherP Thursday, June 18, 2015 3:11 AM
    Thursday, June 18, 2015 2:58 AM

All replies

  • VBScript is on sustained maintenance. No upgrades but will have any major bugs fixed.

    It is used everywhere and won't be pulled.

    If adding as a scripting language then you don't use WSH (your app is the new WSH) but add a script control. If you want the WScript object (and this doesn't apply to sub objects like wscript.shell) available then you have to provide them as the host of the vbs environment,

    his is a vbscript running vbscript macros.

    Sub VBSCmd
     RawScript = LCase(Arg(1))
     'Remove ^ from quoting command line and replace : with vbcrlf so get line number if error
     Script = Replace(RawScript, "^", "")
     Script = Replace(Script, "'", chr(34))
     Script = Replace(Script, ":", vbcrlf)
     'Building the script with predefined statements and the user's code
     Script = "Dim gU" & vbcrlf & "Dim gdU" & vbcrlf & "Set gdU = CreateObject(" & chr(34) & "Scripting.Dictionary" & chr(34) & ")" & vbcrlf & "Function UF(L, LC)" & vbcrlf & "Set greU = New RegExp" & vbcrlf & "On Error Resume Next" & vbcrlf & Script & vbcrlf & "End Function" & vbcrlf

     'Testing the script for syntax errors
     On Error Resume Next
     set ScriptControl1 = wscript.createObject("MSScriptControl.ScriptControl",SC)
         With ScriptControl1
            .Language = "VBScript"
            .UseSafeSubset = False
            .AllowUI = True
      .AddCode Script
     End With
     With ScriptControl1.Error
      If .number <> 0 then
       Outp.WriteBlankLines(1)
       Outp.WriteLine "User function syntax error"
       Outp.WriteLine "=========================="
       Outp.WriteBlankLines(1)
       Outp.Write NumberScript(Script)
       Outp.WriteBlankLines(2)
       Outp.WriteLine "Error " & .number & " " & .description
       Outp.WriteLine "Line " & .line & " " & "Col " & .column
       Exit Sub
      End If
     End With

     ExecuteGlobal(Script)

     'Remove the first line as the parameters are the first line
     'Line=Inp.readline 
     Do Until Inp.AtEndOfStream
      Line=Inp.readline
      LineCount = Inp.Line
      
      temp = UF(Line, LineCount)
      If err.number <> 0 then
       outp.writeline ""
       outp.writeline ""
       outp.writeline "User function runtime error"
       outp.writeline "==========================="
       Outp.WriteBlankLines(1)
       Outp.Write NumberScript(Script)
       Outp.WriteBlankLines(2)
       Outp.WriteLine "Error " & err.number & " " & err.description
       Outp.WriteLine "Source " & err.source

       Outp.WriteLine "Line number and column not available for runtime errors"
       wscript.quit
      End If
      outp.writeline temp
     Loop
    End Sub


    David Candy

    Thursday, June 18, 2015 10:48 PM