What I wanted to do tonight was to call the WScript.Shell object from within a Zeus macro and I thought, this should work, since it is the other way around. Instead I got a dialog, that told me, that the scripting engine has found a problem, that this is, most likley, not a bug in Zeus but may be one in the scripting DLL.
Here is the zeus.debug() output:
Code: Select all
Debug: Debug: Macro trace debugging is active.
Debug: GetIDsOfNames call succeeded.
Debug: screen_update_disable
Debug: GetIDsOfNames call succeeded.
Debug: macro_tag
Debug: GetIDsOfNames call succeeded.
Debug: is_document
Debug: GetIDsOfNames call succeeded.
Debug: is_marked
Debug: GetIDsOfNames call succeeded.
Debug: MarkCopy
Debug: GetIDsOfNames call succeeded.
Debug: MarkHide
Debug: GetIDsOfNames call succeeded.
Debug: get_clipboard_text
Scripting Error :>  File: E:\zfw\zScript\run-in-IE.js (29:2) >>
Reason: 'WScript' ist undefiniert
Debug: Script object destroyed.
Macro script generated '17' Debug, Error and/or Warning message(s).
"d:\work\zeus3.96\apollo\zfwhlp01.cpp" (337)    Unexpected error opening the 'E:\zfw\zHelp\yuiapi.zix' information file.Oh, and here is the (unfinished) script I am having the problem with:
Code: Select all
// Name: 		run-in-IE.js
// Host: 		Zeus for Windows
// Purpose:	Utility for WindowsScript development. Takes the active
//					document (or a marked area), wraps it into HTML and executes
//					it on the IExplorer scripting host.
// TODO:		Add argument parsing, document-type recognition, user-input,
//					special HTA routines (maybe defined in a project specific
//					configuration). Error-Checking.
function key_macro() {
	zeus.debug_enable();															// report to Zeus Debugger
	debugger;																					// should open Windows Script Debugger, does not. May need WSH object.
	zeus.screen_update_disable();											// lock Zeus
	fname = zeus.macro_tag('$FileName');
	if (zeus.is_document() == 1) {
 		if (zeus.is_marked() == 0) {										// if document has no mark set
			zeus.MarkSelectAll();													// mark it all
			zeus.MarkCopy();															// copy to clipboard
			zeus.MarkHide();															// release mark
			buf = zeus.get_clipboard_text();							// and paste that into a buffer
		};
		else {
			// if document has mark set, use this
			zeus.MarkCopy();
			zeus.MarkHide();
			buf = zeus.get_clipboard_text();
		};
	};
		var wsh = new ActiveXObject('WScript.Shell');									// create a WSH
		var fso = new ActiveXObject('Scripting.FileSystemObject');		// and a FileSystem Object
		// TODO:
		// parse args, they contain the filetype we are currently working
		// with. If JS we call makeHTML() and pass it to IE, if HTA we
		// pass it directly to HTA.exe
		oArgs = WScript.Arguments;
		// construct TempFile name
		var uenv = wsh.Environment('USER');
		var TmpFile = fso.BuildPath(uenv('TEMP'), 'zfwtmp.html');
		var oTmpFile = fso.CreateTextFile(tmpfile, True);							// open TempFile for write
		makeHTML('js',buf);																						// call our utility function
		// TODO: Error checking
		// Run our TempFile in IExplorer
		zeus.system("iexplore.exe " + TmpFile, zeus.macro_tag('$FileDir'), 1, "Running in Internet Explorer...");
	// preliminary HTML creation routine
	// TODO: Error-Checking
	function makeHTML(lang_type, editor_text) {
		oTmpFile.WriteLine('<html>');
		oTmpFile.WriteLine('<head>');
		oTmpFile.WriteLine('<title>Testing...</title>');
		if (lang_type == 'js') {
			oTmpFile.WriteLine('<script language=\"Javascript\">');
			oTmpFile.Write(editor_text);
			oTmpFile.WriteLine('</script>');
		};
		oTmpFile.WriteLine('</head>');
		oTmpFile.WriteLine('<body>');
		oTmpFile.WriteLine('</body>');
		oTmpFile.WriteLine('</html>');
	};
	// release Zeus
	zeus.screen_update_enable();
	zeus.screen_update();
};
// run macro
key_macro();