How to run VBScript from command line without Cscript/Wscript

后端 未结 5 618
慢半拍i
慢半拍i 2020-12-17 10:45

I am a beginner in VBScript. I googled it & got to know that we can run VBScript from command line by executing below command:

For Example my vbscript name is

5条回答
  •  情书的邮戳
    2020-12-17 11:25

    Why don't you just stash the vbscript in a batch/vbscript file hybrid. Name the batch hybrid Converter.bat and you can execute it directly as Converter from the cmd line. Sure you can default ALL scripts to run from Cscript or Wscript, but if you want to execute your vbs as a windows script rather than a console script, this could cause some confusion later on. So just set your code to a batch file and run it directly.

    Check the answer -> Here

    And here is an example:

    Converter.bat

    ::' VBS/Batch Hybrid
    ::' --- Batch portion ---------
    rem^ &@echo off
    rem^ &call :'sub
    rem^ &exit /b
    
    :'sub
    rem^ &echo begin batch
    rem^ &cscript //nologo //e:vbscript "%~f0"
    rem^ &echo end batch
    rem^ &exit /b
    
    '----- VBS portion -----
    Dim tester
    tester = "Convert data here"
    Msgbox tester
    

提交回复
热议问题