Calling a .VBS class from a .Bat

Microsoft Windows 7 professional - upgra...
July 28, 2010 at 06:32:33
Specs: Windows XP
Is it possible to call a class in a .vbs File from a .bat file ?

I ie
call <<CLASS>> from addstuff.vbs and execute on "this.txt"


See More: Calling a .VBS class from a .Bat

Report •

#1
July 28, 2010 at 13:06:25
You cannot choose your entry point in a VBS. You can, however, have your script accept arguments and branch to the class you want from the VBScript.

Report •

#2
July 29, 2010 at 09:54:49
can you give an example please.

Report •

#3
July 29, 2010 at 10:23:17
Sure:
If WScript.Arguments.Count Then
  Select Case LCase(WScript.Arguments(0))
    Case "dosomething"
      doSomething
    REM Case "dosomethingelse"
      doSomethingElse
    Case Else
      WScript.Echo "Nothing done"
      WScript.Echo WScript.ScriptName & " [ doSomething | doSomethingElse ]"
  End Select
Else
  WScript.Echo "Nothing to do"
  WScript.Echo WScript.ScriptName & " [ doSomething | doSomethingElse ]"
End If
WScript.Quit

Sub doSomething
  WScript.Echo "Something done"
End Sub

Sub doSomethingElse
  WScript.Echo "Something else done, but don't tell anyone"
End Sub


Report •
Related Solutions


Ask Question