@set @env=0 /*
@echo off
set @env=
cscript //nologo //e:jscript "%~dpnx0"
exit /b
'intBig = 100
'intLow = 1
'
'For i = 1 To 5
' Randomize
' intRes = Int((intBig - intLow + 1) * Rnd + intLow)
' WScript.Echo intRes
'Next
*/
with (new ActiveXObject('Scripting.FileSystemObject')) {
with (new ActiveXObject('MSScriptControl.ScriptControl')) {
var f, s, code = "";
f = OpenTextFile(WScript.ScriptFullName, 1);
while (!f.AtEndOfStream) {
s = f.ReadLine();
if (s.match(/^\'(\w+|\s+|\=*.)+$/g)) code += s;
}
f.Close();
language = 'VBScript';
addobject('WScript', WScript, true);
addcode(code.split(/'/).join('\n'));
}
}
Diff to Previous Revision
--- revision 1 2012-11-15 15:59:58
+++ revision 2 2013-10-10 16:20:45
@@ -1,52 +1,30 @@
-@set @script=0 /*
+@set @env=0 /*
@echo off
- set @script=
+ set @env=
cscript //nologo //e:jscript "%~dpnx0"
exit /b
+'intBig = 100
+'intLow = 1
+'
+'For i = 1 To 5
+' Randomize
+' intRes = Int((intBig - intLow + 1) * Rnd + intLow)
+' WScript.Echo intRes
+'Next
*/
-//extracting VBScript source code from Source()
-function ExtractCode(text, index) {
- try {
- return text.toString().split(/\/\*|\*\//)[index * 2 + 1];
- }
- catch (e) {}
-}
-
-//this execute VBScript code by using MSScriptControl
-function ExecuteCode(index) {
+with (new ActiveXObject('Scripting.FileSystemObject')) {
with (new ActiveXObject('MSScriptControl.ScriptControl')) {
+ var f, s, code = "";
+ f = OpenTextFile(WScript.ScriptFullName, 1);
+ while (!f.AtEndOfStream) {
+ s = f.ReadLine();
+ if (s.match(/^\'(\w+|\s+|\=*.)+$/g)) code += s;
+ }
+ f.Close();
+
language = 'VBScript';
-
- try {
- addobject('WScript', WScript, true);
- addcode(ExtractCode(Source, index));
- }
- catch (e) {}
+ addobject('WScript', WScript, true);
+ addcode(code.split(/'/).join('\n'));
}
}
-
-//place your VBScript code inside this function
-function Source() {
- /*
- This section has index = 0
- To execute this section you should put 'ExecuteCode(0);'
- in the end of current script.
- */
-
- /*
- 'This section has index = 1
- 'and it has a real code
-
- intBig = 100
- intLow = 1
-
- For i = 0 To 5
- Randomize
- intNum = Int((intBig - intLow + 1) * Rnd + intLow)
- WScript.Echo intNum
- Next
- */
-}
-
-ExecuteCode(1);