Thursday, November 23, 2006

[VBScript] Configure

Below is retake on the Include subroutine which heads up the vast majority of my scripts. This incarnation puts a wrapper around Include and is called, for want of a better word, Configure. This subroutine takes no parameters at all. Rather, it builds up a filename based on WScript.ScriptFullName with ".cfg" tagged on, reads it in and then hands it over to ExecuteGlobal. This means that the .cfg file must contain functioning VBScript code.

Provided the .cfg sits side-by-side with the .vbs, the .vbs should work. And if you change locations, change the .cfg code. If the .cfg can't be found, you get an error message. I haven't put in any error trapping yet.

Had fun with "With"/"End With" on this one.

So in the .vbs we have
and in the .cfg we have (for example)

1 comment:

Anonymous said...