Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

select script engine in script

select script engine in script

select script engine in script


I want to write some console scripts that will need stdio, so they have to run in cscript rather than wscript.  I want to be able to run the scripts by typing their name plus arguments at the command line.

Is it possible to specify in the script which engine to use?  If possible, I would prefer to avoid using a .wsh file, registering a default engine through the //E argument to cscript, or sending my script as an argument to cscript.

I'm not worried whether I use vbscript, jscript or some other.

Any help appreciated.

RE: select script engine in script

This is the standard device to force a hosting by cscript despite all oddity. Add the sub force_cscript and place a call to it at the top of the script. (I think I had long time ago posted something similar to a similar thread.)

'Force a cscript host

sub force_cscript
    dim args : args=""
    dim i, wshshell
    If right(lCase(wscript.fullname),11)= "wscript.exe" then
        for i=0 to wscript.arguments.count-1
            args = args & wscript.arguments(i) & " "
        set wshshell=createobject("wscript.shell")
        wshshell.run wshshell.ExpandEnvironmentStrings("%comspec%") & _
            " /c cscript.exe //nologo """ & wscript.scriptfullname & """" & args    'change to /k for stay
        set wshshell=nothing
    end if
end sub

Feel free to add other switches to cscript like " //b " after cscript.exe appeared in the .run line.

RE: select script engine in script

Thank you - have a star!

Sorry I didn't spot it in wherever the other thread is.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close