Including multiple script files with Windows scripting

18Aug10

I’m using a Javascript library in order to do some data manipulation, and I wondered if there was a way to include the source JS file in my script. There is nothing like an include directive in WSH but it does support a mechanism for managing script files that is very similar to how it would work in a Web browser. To do this we create a file with the .wsf extension:

<job>
  <script language="JScript" src="library.js"/>
  <script language="JScript" src="main.js"/>
    <script language="JScript">
       WScript.Echo( doFunction() );
    </script>
</job>

Note that we can include files as well as inline code. The wsf script can now be invoked on the commandline with cscript as you would any vbs or js script file.

Advertisements


No Responses Yet to “Including multiple script files with Windows scripting”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: