6

When you execute a file with .VBS, .JS or .WSF extensions via CScript.exe, they execute correctly:

CScript vbsProg.vbs
CScript jsProg.js
CScript wshScript.wsf

However, we may use //E:engine option to run VBS or JScript files with different extensions:

CScript //E:VBS vbsProg.txt
CScript //E:JScript jsProg.txt

Is there any way to do the same thing with a WSF file?

CScript //E:WhatGoesHere wshScript.txt

Is there any place where script engine names are documented? Is there any way to know the names of all installed engines?

Thanks!

Antonio

Aacini
  • 65,180
  • 12
  • 72
  • 108
  • I have a similar issue. I'm trying to call a WSF from another WSF, but it keeps failing. Have you had any luck? – meffordm Feb 11 '13 at 16:30
  • @meffordm: See the [new answer](http://stackoverflow.com/questions/14629123/how-to-know-valid-script-engine-names-for-cscript-exes-eengine-option/23328598#23328598) below... – Aacini Apr 27 '14 at 20:36

2 Answers2

4

[EDIT] After reading Ekkehard Horner comment I decide to strike out my first sentence about //E switch.

The WSF itself is a batch-job file that may hold scripts in different languages like:

<package>
  <job>
    <script language="VBScript">
      WScript.Echo "Echo from VBScript"
    </script>
    <script language="JScript">
      WScript.Echo("Echo from JScript");
    </script>
    <script language="XYZ">
      //where XYZ s`d be a valid name of installed language
    </script>
  </job>
</package>

And //E is not applicable to WSF files at all. CScript recognize them only by their extension, that mean the only way to run WSF via CScript is:

CScript ScriptName.WSF
Panayot Karabakalov
  • 3,109
  • 3
  • 19
  • 28
  • "you can't use engine switch //E for something else than VBS or JScript" is wrong. Given an installed ActiveState Perl //E:PerlScript works ok (that I can prove). All installed ActiveScript language names are (probably) valid parameters for //E. However, your conclusion wrt to .WSF may well be right. – Ekkehard.Horner Jan 31 '13 at 16:36
  • "All installed ActiveScript language names are (probably) valid parameters for //E" - this is new to me, what to say, probably you're rigth. – Panayot Karabakalov Jan 31 '13 at 17:03
  • +1 for improvement, although I'm very unhappy about the conclusion "no WSF value for the //E: switch". – Ekkehard.Horner Jan 31 '13 at 17:33
  • 4
    Is there any way to know the names of "all installed ActiveScript languages"? – Aacini Jan 31 '13 at 17:51
  • @Ekkehard.Horner - Thanks, as for WSF... is not Script Engine, right? At least has not such keys into Win Registry. – Panayot Karabakalov Jan 31 '13 at 20:43
  • @Aacini - This is not easy question for me. Searching into Win Registry... but it's a bit of hell. I hope someone to know better way. – Panayot Karabakalov Jan 31 '13 at 20:47
3

Although there is no way to know the names of the installed engines for CScript //E: command, there is a very simple way to execute a file with any extension as a .wsf one:

CScript wshScript.txt?.wsf

Further details at this post.

Aacini
  • 65,180
  • 12
  • 72
  • 108