WSH 5.6 Beta 1, new method, WScript.Exec
Author |
Message |
Robert L. Stoke #1 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, Beta 1. According to Clinick this method "introduces the ability to start programs or scripts in a command process that shares all the environment variables of the parent script. It also allows the parent script to capture any output from the child process." I have been unable to find more information about WScript.Exec. My unsuccessful research is listed below. Can anyone suggest additional sources, or provided a simple example? --- Unsuccessful research ----- 1. Microsoft Knowledge base ( http://www.*-*-*.com/ ). Nothing comes up under "WScript.Exec" or "Exec" 2. WSH documentation ( http://www.*-*-*.com/ wshtoc.htm) "Exec" does not appear in the alphabetic keyword list. 3. Clinick offer a code example by Michael Whalens. The following line includes the first reference to the Exec method. See the complete example at the end of this post. var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); I rewrote Walens example as the following two line program, which produced the indicated error. I did not expect it to work. set shell = createobject("WScript.shell") set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") Type mismatch: '[string: "%comspec% /c dir \" "]' Having no success finding the syntax of the exec method, I gave up. --- complete Whalens example --- <package> <job id="ExecDemo"> <runtime> <description> *********************************************** * The Amazing Directory Filter Script!!!! * *********************************************** This script will filter out unwanted file types from your directory listing, using the powers of script and Windows Script Host. *********************************************** </description> <named name="d" helpstring="The directory to list." type="string" required="false" /> <named name="s" helpstring="Show the extensions in the list." type="simple" required="false" /> <unnamed name="filetype" helpstring="A file type to show or ignore." many="true" required="false" /> <example> *********************************************** You may include any number of file types. By default, the types will be filtered from the list - use /s to filter all other types from the list. If no files types are indicated, then a full directory listing will be displayed. *********************************************** Example: dirfilter /d:c:\ /s js vbs wsf This will display all js, vbs, and wsf files in the directory. *********************************************** </example> </runtime> <object id="oShell" progid="WScript.Shell"/> <script language="JScript"> var i; // counting variable var bShow = WScript.Arguments.Named.Exists("s"); var cTypeCount = WScript.Arguments.Unnamed.length; if (0 == cTypeCount) bShow = false; var aList = new Array(cTypeCount); for (i = 0; i < cTypeCount; i++) aList[i] = WScript.Arguments.Unnamed(i); var sDir = oShell.CurrentDirectory; if (WScript.Arguments.Named.Exists("d")) sDir = WScript.Arguments.Named("d"); var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); var sText = ""; var quit = false; for (;;) { if (!oExec.StdOut.AtEndOfStream) sText += oExec.StdOut.ReadAll(); if (quit) break; if (oExec.status == 1) quit = true; else WScript.Sleep(100); Quote: }
var aText = sText.split("\n"); var cTextCount = aText.length; sText = ""; for (i = 5; i < cTextCount - 3; i++) if (CheckLine(aText[i], aList, bShow)) sText += aText[i] + "\n"; WScript.Echo(sText); function CheckLine(sStr, aList, bShow) { var iExt = sStr.lastIndexOf(".") + 1; if (0 == iExt) return !bShow; var sExt = String(sStr.substring(iExt, sStr.length - 1)); for (var i = 0; i < aList.length; i++) { if (sExt == aList[i]) return bShow; } return !bShow; Quote: }
</script> </job> </package>
|
Fri, 10 Oct 2003 11:50:26 GMT |
|
 |
Michael Harri #2 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
It's WshShell.Exec... Even the 5.6 beta docs slip up here and there ;-). The original spec may have been to have it be a method of WScript, but it is definitely a method of WshShell. Take a look with a VB/VBA Object Browser... And the object returned is a WshExec object, not a WshScriptExec object... -- Michael Harris Microsoft.MVP.Scripting --
Please do not email questions - post them to the newsgroup instead. --
Quote: > Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, > Beta 1. According to Clinick this method "introduces the ability to start > programs or scripts in a command process that shares all the environment > variables of the parent script. It also allows the parent script to capture > any output from the child process." > I have been unable to find more information about WScript.Exec. My > unsuccessful research is listed below. Can anyone suggest additional > sources, or provided a simple example? > --- Unsuccessful research ----- > 1. Microsoft Knowledge base (http://search.support.microsoft.com/kb/c.asp). > Nothing comes up under "WScript.Exec" or "Exec" > 2. WSH documentation > (http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... > wshtoc.htm) > "Exec" does not appear in the alphabetic keyword list. > 3. Clinick offer a code example by Michael Whalens. The following line > includes the first reference to the Exec method. See the complete example at > the end of this post. > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > I rewrote Walens example as the following two line program, which produced > the indicated error. I did not expect it to work. > set shell = createobject("WScript.shell") > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > Type mismatch: '[string: "%comspec% /c dir \" "]' > Having no success finding the syntax of the exec method, I gave up. > --- complete Whalens example --- > <package> > <job id="ExecDemo"> > <runtime> > <description> > *********************************************** > * The Amazing Directory Filter Script!!!! * > *********************************************** > This script will filter out unwanted file > types from your directory listing, using the > powers of script and Windows Script Host. > *********************************************** > </description> > <named > name="d" > helpstring="The directory to list." > type="string" > required="false" > /> > <named > name="s" > helpstring="Show the extensions in the list." > type="simple" > required="false" > /> > <unnamed > name="filetype" > helpstring="A file type to show or ignore." > many="true" > required="false" > /> > <example> > *********************************************** > You may include any number of file types. > By default, the types will be filtered from > the list - use /s to filter all other types > from the list. If no files types are > indicated, then a full directory listing > will be displayed. > *********************************************** > Example: > dirfilter /d:c:\ /s js vbs wsf > This will display all js, vbs, and wsf > files in the directory. > *********************************************** > </example> > </runtime> > <object id="oShell" progid="WScript.Shell"/> > <script language="JScript"> > var i; // counting variable > var bShow = WScript.Arguments.Named.Exists("s"); > var cTypeCount = WScript.Arguments.Unnamed.length; > if (0 == cTypeCount) > bShow = false; > var aList = new Array(cTypeCount); > for (i = 0; i < cTypeCount; i++) > aList[i] = WScript.Arguments.Unnamed(i); > var sDir = oShell.CurrentDirectory; > if (WScript.Arguments.Named.Exists("d")) > sDir = WScript.Arguments.Named("d"); > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > var sText = ""; > var quit = false; > for (;;) > { > if (!oExec.StdOut.AtEndOfStream) > sText += oExec.StdOut.ReadAll(); > if (quit) break; > if (oExec.status == 1) > quit = true; > else > WScript.Sleep(100); > } > var aText = sText.split("\n"); > var cTextCount = aText.length; > sText = ""; > for (i = 5; i < cTextCount - 3; i++) > if (CheckLine(aText[i], aList, bShow)) > sText += aText[i] + "\n"; > WScript.Echo(sText); > function CheckLine(sStr, aList, bShow) > { > var iExt = sStr.lastIndexOf(".") + 1; > if (0 == iExt) > return !bShow; > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > for (var i = 0; i < aList.length; i++) > { > if (sExt == aList[i]) > return bShow; > } > return !bShow; > } > </script> > </job> > </package>
|
Fri, 10 Oct 2003 14:09:39 GMT |
|
 |
JJ #3 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
This script will execute a "dir" command and grab the output and then echo it back to stdout: Dim ExecObj Dim FromProc Set WshShell = WScript.CreateObject("WScript.Shell") Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") Do FromProc = ExecObj.StdOut.ReadLine() WScript.Echo FromProc Loop While Not ExecObj.Stdout.atEndOfStream Note that the above will blow up with an exception-type errror the first time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is enabled. It will run correctly in subsequent attempts because the first attempt locks a cscript.exe process in memory and this affects subsequent runs. But eventually the system will lock up solid because of it. It only does this when you execute something through %COMSPEC% (command.com) or a 16-bit DOS application.
Quote: > Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, > Beta 1. According to Clinick this method "introduces the ability to start > programs or scripts in a command process that shares all the environment > variables of the parent script. It also allows the parent script to capture > any output from the child process." > I have been unable to find more information about WScript.Exec. My > unsuccessful research is listed below. Can anyone suggest additional > sources, or provided a simple example? > --- Unsuccessful research ----- > 1. Microsoft Knowledge base
(http://search.support.microsoft.com/kb/c.asp). Quote: > Nothing comes up under "WScript.Exec" or "Exec" > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > wshtoc.htm) > "Exec" does not appear in the alphabetic keyword list. > 3. Clinick offer a code example by Michael Whalens. The following line > includes the first reference to the Exec method. See the complete example at > the end of this post. > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > I rewrote Walens example as the following two line program, which produced > the indicated error. I did not expect it to work. > set shell = createobject("WScript.shell") > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > Type mismatch: '[string: "%comspec% /c dir \" "]' > Having no success finding the syntax of the exec method, I gave up. > --- complete Whalens example --- > <package> > <job id="ExecDemo"> > <runtime> > <description> > *********************************************** > * The Amazing Directory Filter Script!!!! * > *********************************************** > This script will filter out unwanted file > types from your directory listing, using the > powers of script and Windows Script Host. > *********************************************** > </description> > <named > name="d" > helpstring="The directory to list." > type="string" > required="false" > /> > <named > name="s" > helpstring="Show the extensions in the list." > type="simple" > required="false" > /> > <unnamed > name="filetype" > helpstring="A file type to show or ignore." > many="true" > required="false" > /> > <example> > *********************************************** > You may include any number of file types. > By default, the types will be filtered from > the list - use /s to filter all other types > from the list. If no files types are > indicated, then a full directory listing > will be displayed. > *********************************************** > Example: > dirfilter /d:c:\ /s js vbs wsf > This will display all js, vbs, and wsf > files in the directory. > *********************************************** > </example> > </runtime> > <object id="oShell" progid="WScript.Shell"/> > <script language="JScript"> > var i; // counting variable > var bShow = WScript.Arguments.Named.Exists("s"); > var cTypeCount = WScript.Arguments.Unnamed.length; > if (0 == cTypeCount) > bShow = false; > var aList = new Array(cTypeCount); > for (i = 0; i < cTypeCount; i++) > aList[i] = WScript.Arguments.Unnamed(i); > var sDir = oShell.CurrentDirectory; > if (WScript.Arguments.Named.Exists("d")) > sDir = WScript.Arguments.Named("d"); > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > var sText = ""; > var quit = false; > for (;;) > { > if (!oExec.StdOut.AtEndOfStream) > sText += oExec.StdOut.ReadAll(); > if (quit) break; > if (oExec.status == 1) > quit = true; > else > WScript.Sleep(100); > } > var aText = sText.split("\n"); > var cTextCount = aText.length; > sText = ""; > for (i = 5; i < cTextCount - 3; i++) > if (CheckLine(aText[i], aList, bShow)) > sText += aText[i] + "\n"; > WScript.Echo(sText); > function CheckLine(sStr, aList, bShow) > { > var iExt = sStr.lastIndexOf(".") + 1; > if (0 == iExt) > return !bShow; > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > for (var i = 0; i < aList.length; i++) > { > if (sExt == aList[i]) > return bShow; > } > return !bShow; > } > </script> > </job> > </package>
|
Fri, 10 Oct 2003 21:59:18 GMT |
|
 |
Robert L. Stoke #4 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Thanks Michael Harris. Getting the name right is helpful. However, searching the Microsoft knowledge base and the alphabetic keyword list of WSH elements for "WshShell.Exec" or "Exec" again produced no references. I do not use Visual Basic, or Visual Basic for Applications. I want to understand how this procedure works in several situations. For that I need the detailed syntax, and, hopefully, some examples. Any other suggestions.
Quote: > It's WshShell.Exec... Even the 5.6 beta docs slip up here and there ;-). > The original spec may have been to have it be a method of WScript, but it
is definitely a method of Quote: > WshShell. Take a look with a VB/VBA Object Browser... And the object
returned is a WshExec object, Quote: > not a WshScriptExec object... > -- > Michael Harris > Microsoft.MVP.Scripting > --
> Please do not email questions - post them to the newsgroup instead. > --
Quote: > > Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, > > Beta 1. According to Clinick this method "introduces the ability to start > > programs or scripts in a command process that shares all the environment > > variables of the parent script. It also allows the parent script to capture > > any output from the child process." > > I have been unable to find more information about WScript.Exec. My > > unsuccessful research is listed below. Can anyone suggest additional > > sources, or provided a simple example? > > --- Unsuccessful research ----- > > 1. Microsoft Knowledge base
(http://search.support.microsoft.com/kb/c.asp). Quote: > > Nothing comes up under "WScript.Exec" or "Exec" > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > wshtoc.htm) > > "Exec" does not appear in the alphabetic keyword list. > > 3. Clinick offer a code example by Michael Whalens. The following line > > includes the first reference to the Exec method. See the complete example at > > the end of this post. > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > I rewrote Walens example as the following two line program, which produced > > the indicated error. I did not expect it to work. > > set shell = createobject("WScript.shell") > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > Having no success finding the syntax of the exec method, I gave up. > > --- complete Whalens example --- > > <package> > > <job id="ExecDemo"> > > <runtime> > > <description> > > *********************************************** > > * The Amazing Directory Filter Script!!!! * > > *********************************************** > > This script will filter out unwanted file > > types from your directory listing, using the > > powers of script and Windows Script Host. > > *********************************************** > > </description> > > <named > > name="d" > > helpstring="The directory to list." > > type="string" > > required="false" > > /> > > <named > > name="s" > > helpstring="Show the extensions in the list." > > type="simple" > > required="false" > > /> > > <unnamed > > name="filetype" > > helpstring="A file type to show or ignore." > > many="true" > > required="false" > > /> > > <example> > > *********************************************** > > You may include any number of file types. > > By default, the types will be filtered from > > the list - use /s to filter all other types > > from the list. If no files types are > > indicated, then a full directory listing > > will be displayed. > > *********************************************** > > Example: > > dirfilter /d:c:\ /s js vbs wsf > > This will display all js, vbs, and wsf > > files in the directory. > > *********************************************** > > </example> > > </runtime> > > <object id="oShell" progid="WScript.Shell"/> > > <script language="JScript"> > > var i; // counting variable > > var bShow = WScript.Arguments.Named.Exists("s"); > > var cTypeCount = WScript.Arguments.Unnamed.length; > > if (0 == cTypeCount) > > bShow = false; > > var aList = new Array(cTypeCount); > > for (i = 0; i < cTypeCount; i++) > > aList[i] = WScript.Arguments.Unnamed(i); > > var sDir = oShell.CurrentDirectory; > > if (WScript.Arguments.Named.Exists("d")) > > sDir = WScript.Arguments.Named("d"); > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > var sText = ""; > > var quit = false; > > for (;;) > > { > > if (!oExec.StdOut.AtEndOfStream) > > sText += oExec.StdOut.ReadAll(); > > if (quit) break; > > if (oExec.status == 1) > > quit = true; > > else > > WScript.Sleep(100); > > } > > var aText = sText.split("\n"); > > var cTextCount = aText.length; > > sText = ""; > > for (i = 5; i < cTextCount - 3; i++) > > if (CheckLine(aText[i], aList, bShow)) > > sText += aText[i] + "\n"; > > WScript.Echo(sText); > > function CheckLine(sStr, aList, bShow) > > { > > var iExt = sStr.lastIndexOf(".") + 1; > > if (0 == iExt) > > return !bShow; > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > for (var i = 0; i < aList.length; i++) > > { > > if (sExt == aList[i]) > > return bShow; > > } > > return !bShow; > > } > > </script> > > </job> > > </package>
|
Fri, 10 Oct 2003 22:59:38 GMT |
|
 |
MS #5 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
The Knowledge Base (and pretty much all of the standard MSDN documentation) is for released products. For beta products, you generally have to download the beta documentation - searching the database won't find anything. Our beta documentation is available on our beta download page - go to http://msdn.microsoft.com/scripting, click on the link under "Windows Script 5.6 Beta 2 Released", and the docs are at linked at the bottom of the page. Mike Whalen Windows Script Dev
Quote: > Thanks Michael Harris. Getting the name right is helpful. However, > searching the Microsoft knowledge base and the alphabetic keyword list of > WSH elements for "WshShell.Exec" or "Exec" again produced no references. I > do not use Visual Basic, or Visual Basic for Applications. I want to > understand how this procedure works in several situations. For that I need > the detailed syntax, and, hopefully, some examples. > Any other suggestions.
> > It's WshShell.Exec... Even the 5.6 beta docs slip up here and there ;-). > > The original spec may have been to have it be a method of WScript, but it > is definitely a method of > > WshShell. Take a look with a VB/VBA Object Browser... And the object > returned is a WshExec object, > > not a WshScriptExec object... > > -- > > Michael Harris > > Microsoft.MVP.Scripting > > --
> > Please do not email questions - post them to the newsgroup instead. > > --
> > > Andrew Clinick describes WScript.Exec as a new method included in WSH > 5.6, > > > Beta 1. According to Clinick this method "introduces the ability to > start > > > programs or scripts in a command process that shares all the environment > > > variables of the parent script. It also allows the parent script to > capture > > > any output from the child process." > > > I have been unable to find more information about WScript.Exec. My > > > unsuccessful research is listed below. Can anyone suggest additional > > > sources, or provided a simple example? > > > --- Unsuccessful research ----- > > > 1. Microsoft Knowledge base > (http://search.support.microsoft.com/kb/c.asp). > > > Nothing comes up under "WScript.Exec" or "Exec" > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > wshtoc.htm) > > > "Exec" does not appear in the alphabetic keyword list. > > > 3. Clinick offer a code example by Michael Whalens. The following line > > > includes the first reference to the Exec method. See the complete > example at > > > the end of this post. > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > I rewrote Walens example as the following two line program, which > produced > > > the indicated error. I did not expect it to work. > > > set shell = createobject("WScript.shell") > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > Having no success finding the syntax of the exec method, I gave up. > > > --- complete Whalens example --- > > > <package> > > > <job id="ExecDemo"> > > > <runtime> > > > <description> > > > *********************************************** > > > * The Amazing Directory Filter Script!!!! * > > > *********************************************** > > > This script will filter out unwanted file > > > types from your directory listing, using the > > > powers of script and Windows Script Host. > > > *********************************************** > > > </description> > > > <named > > > name="d" > > > helpstring="The directory to list." > > > type="string" > > > required="false" > > > /> > > > <named > > > name="s" > > > helpstring="Show the extensions in the list." > > > type="simple" > > > required="false" > > > /> > > > <unnamed > > > name="filetype" > > > helpstring="A file type to show or ignore." > > > many="true" > > > required="false" > > > /> > > > <example> > > > *********************************************** > > > You may include any number of file types. > > > By default, the types will be filtered from > > > the list - use /s to filter all other types > > > from the list. If no files types are > > > indicated, then a full directory listing > > > will be displayed. > > > *********************************************** > > > Example: > > > dirfilter /d:c:\ /s js vbs wsf > > > This will display all js, vbs, and wsf > > > files in the directory. > > > *********************************************** > > > </example> > > > </runtime> > > > <object id="oShell" progid="WScript.Shell"/> > > > <script language="JScript"> > > > var i; // counting variable > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > if (0 == cTypeCount) > > > bShow = false; > > > var aList = new Array(cTypeCount); > > > for (i = 0; i < cTypeCount; i++) > > > aList[i] = WScript.Arguments.Unnamed(i); > > > var sDir = oShell.CurrentDirectory; > > > if (WScript.Arguments.Named.Exists("d")) > > > sDir = WScript.Arguments.Named("d"); > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > var sText = ""; > > > var quit = false; > > > for (;;) > > > { > > > if (!oExec.StdOut.AtEndOfStream) > > > sText += oExec.StdOut.ReadAll(); > > > if (quit) break; > > > if (oExec.status == 1) > > > quit = true; > > > else > > > WScript.Sleep(100); > > > } > > > var aText = sText.split("\n"); > > > var cTextCount = aText.length; > > > sText = ""; > > > for (i = 5; i < cTextCount - 3; i++) > > > if (CheckLine(aText[i], aList, bShow)) > > > sText += aText[i] + "\n"; > > > WScript.Echo(sText); > > > function CheckLine(sStr, aList, bShow) > > > { > > > var iExt = sStr.lastIndexOf(".") + 1; > > > if (0 == iExt) > > > return !bShow; > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > for (var i = 0; i < aList.length; i++) > > > { > > > if (sExt == aList[i]) > > > return bShow; > > > } > > > return !bShow; > > > } > > > </script> > > > </job> > > > </package>
|
Sat, 11 Oct 2003 02:13:53 GMT |
|
 |
jim_ #6 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Yes, and this behavior was NOT fixed in beta 2. And, btw, I have an app that does exactly that. However, if I run it using the CreateProcess api (which I assume ms is using also), it runs just fine, jw Quote:
> This script will execute a "dir" command and grab the output and then echo > it back to stdout: > Dim ExecObj > Dim FromProc > Set WshShell = WScript.CreateObject("WScript.Shell") > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > Do > FromProc = ExecObj.StdOut.ReadLine() > WScript.Echo FromProc > Loop While Not ExecObj.Stdout.atEndOfStream > Note that the above will blow up with an exception-type errror the first > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > enabled. It will run correctly in subsequent attempts because the first > attempt locks a cscript.exe process in memory and this affects subsequent > runs. But eventually the system will lock up solid because of it. It only > does this when you execute something through %COMSPEC% (command.com) or a > 16-bit DOS application.
> > Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, > > Beta 1. According to Clinick this method "introduces the ability to start > > programs or scripts in a command process that shares all the environment > > variables of the parent script. It also allows the parent script to > capture > > any output from the child process." > > I have been unable to find more information about WScript.Exec. My > > unsuccessful research is listed below. Can anyone suggest additional > > sources, or provided a simple example? > > --- Unsuccessful research ----- > > 1. Microsoft Knowledge base > (http://search.support.microsoft.com/kb/c.asp). > > Nothing comes up under "WScript.Exec" or "Exec" > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > wshtoc.htm) > > "Exec" does not appear in the alphabetic keyword list. > > 3. Clinick offer a code example by Michael Whalens. The following line > > includes the first reference to the Exec method. See the complete example > at > > the end of this post. > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > I rewrote Walens example as the following two line program, which produced > > the indicated error. I did not expect it to work. > > set shell = createobject("WScript.shell") > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > Having no success finding the syntax of the exec method, I gave up. > > --- complete Whalens example --- > > <package> > > <job id="ExecDemo"> > > <runtime> > > <description> > > *********************************************** > > * The Amazing Directory Filter Script!!!! * > > *********************************************** > > This script will filter out unwanted file > > types from your directory listing, using the > > powers of script and Windows Script Host. > > *********************************************** > > </description> > > <named > > name="d" > > helpstring="The directory to list." > > type="string" > > required="false" > > /> > > <named > > name="s" > > helpstring="Show the extensions in the list." > > type="simple" > > required="false" > > /> > > <unnamed > > name="filetype" > > helpstring="A file type to show or ignore." > > many="true" > > required="false" > > /> > > <example> > > *********************************************** > > You may include any number of file types. > > By default, the types will be filtered from > > the list - use /s to filter all other types > > from the list. If no files types are > > indicated, then a full directory listing > > will be displayed. > > *********************************************** > > Example: > > dirfilter /d:c:\ /s js vbs wsf > > This will display all js, vbs, and wsf > > files in the directory. > > *********************************************** > > </example> > > </runtime> > > <object id="oShell" progid="WScript.Shell"/> > > <script language="JScript"> > > var i; // counting variable > > var bShow = WScript.Arguments.Named.Exists("s"); > > var cTypeCount = WScript.Arguments.Unnamed.length; > > if (0 == cTypeCount) > > bShow = false; > > var aList = new Array(cTypeCount); > > for (i = 0; i < cTypeCount; i++) > > aList[i] = WScript.Arguments.Unnamed(i); > > var sDir = oShell.CurrentDirectory; > > if (WScript.Arguments.Named.Exists("d")) > > sDir = WScript.Arguments.Named("d"); > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > var sText = ""; > > var quit = false; > > for (;;) > > { > > if (!oExec.StdOut.AtEndOfStream) > > sText += oExec.StdOut.ReadAll(); > > if (quit) break; > > if (oExec.status == 1) > > quit = true; > > else > > WScript.Sleep(100); > > } > > var aText = sText.split("\n"); > > var cTextCount = aText.length; > > sText = ""; > > for (i = 5; i < cTextCount - 3; i++) > > if (CheckLine(aText[i], aList, bShow)) > > sText += aText[i] + "\n"; > > WScript.Echo(sText); > > function CheckLine(sStr, aList, bShow) > > { > > var iExt = sStr.lastIndexOf(".") + 1; > > if (0 == iExt) > > return !bShow; > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > for (var i = 0; i < aList.length; i++) > > { > > if (sExt == aList[i]) > > return bShow; > > } > > return !bShow; > > } > > </script> > > </job> > > </package>
|
Sat, 11 Oct 2003 02:38:40 GMT |
|
 |
JJ #7 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Jim, BTW, I think the problem is in NAV, not in WSH. I can reproduce it with pure C code also, where WSH is not involved at all. I have sent documentation on it to Symantec a few months ago, but never heard anything back from them.
Quote: > Yes, and this behavior was NOT fixed in beta 2. > And, btw, I have an app that does exactly that. However, if I run it using > the CreateProcess api (which I assume ms is using also), it runs just fine, > jw
> > This script will execute a "dir" command and grab the output and then echo > > it back to stdout: > > Dim ExecObj > > Dim FromProc > > Set WshShell = WScript.CreateObject("WScript.Shell") > > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > > Do > > FromProc = ExecObj.StdOut.ReadLine() > > WScript.Echo FromProc > > Loop While Not ExecObj.Stdout.atEndOfStream > > Note that the above will blow up with an exception-type errror the first > > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > > enabled. It will run correctly in subsequent attempts because the first > > attempt locks a cscript.exe process in memory and this affects subsequent > > runs. But eventually the system will lock up solid because of it. It > only > > does this when you execute something through %COMSPEC% (command.com) or a > > 16-bit DOS application.
> > > Andrew Clinick describes WScript.Exec as a new method included in WSH > 5.6, > > > Beta 1. According to Clinick this method "introduces the ability to > start > > > programs or scripts in a command process that shares all the environment > > > variables of the parent script. It also allows the parent script to > > capture > > > any output from the child process." > > > I have been unable to find more information about WScript.Exec. My > > > unsuccessful research is listed below. Can anyone suggest additional > > > sources, or provided a simple example? > > > --- Unsuccessful research ----- > > > 1. Microsoft Knowledge base > > (http://search.support.microsoft.com/kb/c.asp). > > > Nothing comes up under "WScript.Exec" or "Exec" > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > wshtoc.htm) > > > "Exec" does not appear in the alphabetic keyword list. > > > 3. Clinick offer a code example by Michael Whalens. The following line > > > includes the first reference to the Exec method. See the complete > example > > at > > > the end of this post. > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > I rewrote Walens example as the following two line program, which > produced > > > the indicated error. I did not expect it to work. > > > set shell = createobject("WScript.shell") > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > Having no success finding the syntax of the exec method, I gave up. > > > --- complete Whalens example --- > > > <package> > > > <job id="ExecDemo"> > > > <runtime> > > > <description> > > > *********************************************** > > > * The Amazing Directory Filter Script!!!! * > > > *********************************************** > > > This script will filter out unwanted file > > > types from your directory listing, using the > > > powers of script and Windows Script Host. > > > *********************************************** > > > </description> > > > <named > > > name="d" > > > helpstring="The directory to list." > > > type="string" > > > required="false" > > > /> > > > <named > > > name="s" > > > helpstring="Show the extensions in the list." > > > type="simple" > > > required="false" > > > /> > > > <unnamed > > > name="filetype" > > > helpstring="A file type to show or ignore." > > > many="true" > > > required="false" > > > /> > > > <example> > > > *********************************************** > > > You may include any number of file types. > > > By default, the types will be filtered from > > > the list - use /s to filter all other types > > > from the list. If no files types are > > > indicated, then a full directory listing > > > will be displayed. > > > *********************************************** > > > Example: > > > dirfilter /d:c:\ /s js vbs wsf > > > This will display all js, vbs, and wsf > > > files in the directory. > > > *********************************************** > > > </example> > > > </runtime> > > > <object id="oShell" progid="WScript.Shell"/> > > > <script language="JScript"> > > > var i; // counting variable > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > if (0 == cTypeCount) > > > bShow = false; > > > var aList = new Array(cTypeCount); > > > for (i = 0; i < cTypeCount; i++) > > > aList[i] = WScript.Arguments.Unnamed(i); > > > var sDir = oShell.CurrentDirectory; > > > if (WScript.Arguments.Named.Exists("d")) > > > sDir = WScript.Arguments.Named("d"); > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > var sText = ""; > > > var quit = false; > > > for (;;) > > > { > > > if (!oExec.StdOut.AtEndOfStream) > > > sText += oExec.StdOut.ReadAll(); > > > if (quit) break; > > > if (oExec.status == 1) > > > quit = true; > > > else > > > WScript.Sleep(100); > > > } > > > var aText = sText.split("\n"); > > > var cTextCount = aText.length; > > > sText = ""; > > > for (i = 5; i < cTextCount - 3; i++) > > > if (CheckLine(aText[i], aList, bShow)) > > > sText += aText[i] + "\n"; > > > WScript.Echo(sText); > > > function CheckLine(sStr, aList, bShow) > > > { > > > var iExt = sStr.lastIndexOf(".") + 1; > > > if (0 == iExt) > > > return !bShow; > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > for (var i = 0; i < aList.length; i++) > > > { > > > if (sExt == aList[i]) > > > return bShow; > > > } > > > return !bShow; > > > } > > > </script> > > > </job> > > > </package>
|
Sat, 11 Oct 2003 02:52:41 GMT |
|
 |
Michael Harri #8 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
5.6 is still beta...the only documentation of the beta is the 5.6 beta HTMLHelp (.chm) version that can be downloaded from the same page as the beta binaries... -- Michael Harris Microsoft.MVP.Scripting --
Please do not email questions - post them to the newsgroup instead. --
Quote: > Thanks Michael Harris. Getting the name right is helpful. However, > searching the Microsoft knowledge base and the alphabetic keyword list of > WSH elements for "WshShell.Exec" or "Exec" again produced no references. I > do not use Visual Basic, or Visual Basic for Applications. I want to > understand how this procedure works in several situations. For that I need > the detailed syntax, and, hopefully, some examples. > Any other suggestions.
> > It's WshShell.Exec... Even the 5.6 beta docs slip up here and there ;-). > > The original spec may have been to have it be a method of WScript, but it > is definitely a method of > > WshShell. Take a look with a VB/VBA Object Browser... And the object > returned is a WshExec object, > > not a WshScriptExec object... > > -- > > Michael Harris > > Microsoft.MVP.Scripting > > --
> > Please do not email questions - post them to the newsgroup instead. > > --
> > > Andrew Clinick describes WScript.Exec as a new method included in WSH > 5.6, > > > Beta 1. According to Clinick this method "introduces the ability to > start > > > programs or scripts in a command process that shares all the environment > > > variables of the parent script. It also allows the parent script to > capture > > > any output from the child process." > > > I have been unable to find more information about WScript.Exec. My > > > unsuccessful research is listed below. Can anyone suggest additional > > > sources, or provided a simple example? > > > --- Unsuccessful research ----- > > > 1. Microsoft Knowledge base > (http://search.support.microsoft.com/kb/c.asp). > > > Nothing comes up under "WScript.Exec" or "Exec" > > > 2. WSH documentation > (http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... > > > wshtoc.htm) > > > "Exec" does not appear in the alphabetic keyword list. > > > 3. Clinick offer a code example by Michael Whalens. The following line > > > includes the first reference to the Exec method. See the complete > example at > > > the end of this post. > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > I rewrote Walens example as the following two line program, which > produced > > > the indicated error. I did not expect it to work. > > > set shell = createobject("WScript.shell") > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > Having no success finding the syntax of the exec method, I gave up. > > > --- complete Whalens example --- > > > <package> > > > <job id="ExecDemo"> > > > <runtime> > > > <description> > > > *********************************************** > > > * The Amazing Directory Filter Script!!!! * > > > *********************************************** > > > This script will filter out unwanted file > > > types from your directory listing, using the > > > powers of script and Windows Script Host. > > > *********************************************** > > > </description> > > > <named > > > name="d" > > > helpstring="The directory to list." > > > type="string" > > > required="false" > > > /> > > > <named > > > name="s" > > > helpstring="Show the extensions in the list." > > > type="simple" > > > required="false" > > > /> > > > <unnamed > > > name="filetype" > > > helpstring="A file type to show or ignore." > > > many="true" > > > required="false" > > > /> > > > <example> > > > *********************************************** > > > You may include any number of file types. > > > By default, the types will be filtered from > > > the list - use /s to filter all other types > > > from the list. If no files types are > > > indicated, then a full directory listing > > > will be displayed. > > > *********************************************** > > > Example: > > > dirfilter /d:c:\ /s js vbs wsf > > > This will display all js, vbs, and wsf > > > files in the directory. > > > *********************************************** > > > </example> > > > </runtime> > > > <object id="oShell" progid="WScript.Shell"/> > > > <script language="JScript"> > > > var i; // counting variable > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > if (0 == cTypeCount) > > > bShow = false; > > > var aList = new Array(cTypeCount); > > > for (i = 0; i < cTypeCount; i++) > > > aList[i] = WScript.Arguments.Unnamed(i); > > > var sDir = oShell.CurrentDirectory; > > > if (WScript.Arguments.Named.Exists("d")) > > > sDir = WScript.Arguments.Named("d"); > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > var sText = ""; > > > var quit = false; > > > for (;;) > > > { > > > if (!oExec.StdOut.AtEndOfStream) > > > sText += oExec.StdOut.ReadAll(); > > > if (quit) break; > > > if (oExec.status == 1) > > > quit = true; > > > else > > > WScript.Sleep(100); > > > } > > > var aText = sText.split("\n"); > > > var cTextCount = aText.length; > > > sText = ""; > > > for (i = 5; i < cTextCount - 3; i++) > > > if (CheckLine(aText[i], aList, bShow)) > > > sText += aText[i] + "\n"; > > > WScript.Echo(sText); > > > function CheckLine(sStr, aList, bShow) > > > { > > > var iExt = sStr.lastIndexOf(".") + 1; > > > if (0 == iExt) > > > return !bShow; > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > for (var i = 0; i < aList.length; i++) > > > { > > > if (sExt == aList[i]) > > > return bShow; > > > } > > > return !bShow; > > > } > > > </script> > > > </job> > > > </package>
|
Sat, 11 Oct 2003 03:49:19 GMT |
|
 |
Robert L. Stoke #9 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
I ran this code and got the following error Object doesn't support this property or method: 'WshShell.Exec' Quote:
> This script will execute a "dir" command and grab the output and then echo > it back to stdout: > Dim ExecObj > Dim FromProc > Set WshShell = WScript.CreateObject("WScript.Shell") > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > Do > FromProc = ExecObj.StdOut.ReadLine() > WScript.Echo FromProc > Loop While Not ExecObj.Stdout.atEndOfStream > Note that the above will blow up with an exception-type errror the first > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > enabled. It will run correctly in subsequent attempts because the first > attempt locks a cscript.exe process in memory and this affects subsequent > runs. But eventually the system will lock up solid because of it. It only > does this when you execute something through %COMSPEC% (command.com) or a > 16-bit DOS application.
> > Andrew Clinick describes WScript.Exec as a new method included in WSH 5.6, > > Beta 1. According to Clinick this method "introduces the ability to start > > programs or scripts in a command process that shares all the environment > > variables of the parent script. It also allows the parent script to > capture > > any output from the child process." > > I have been unable to find more information about WScript.Exec. My > > unsuccessful research is listed below. Can anyone suggest additional > > sources, or provided a simple example? > > --- Unsuccessful research ----- > > 1. Microsoft Knowledge base > (http://search.support.microsoft.com/kb/c.asp). > > Nothing comes up under "WScript.Exec" or "Exec" > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > wshtoc.htm) > > "Exec" does not appear in the alphabetic keyword list. > > 3. Clinick offer a code example by Michael Whalens. The following line > > includes the first reference to the Exec method. See the complete example > at > > the end of this post. > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > I rewrote Walens example as the following two line program, which produced > > the indicated error. I did not expect it to work. > > set shell = createobject("WScript.shell") > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > Having no success finding the syntax of the exec method, I gave up. > > --- complete Whalens example --- > > <package> > > <job id="ExecDemo"> > > <runtime> > > <description> > > *********************************************** > > * The Amazing Directory Filter Script!!!! * > > *********************************************** > > This script will filter out unwanted file > > types from your directory listing, using the > > powers of script and Windows Script Host. > > *********************************************** > > </description> > > <named > > name="d" > > helpstring="The directory to list." > > type="string" > > required="false" > > /> > > <named > > name="s" > > helpstring="Show the extensions in the list." > > type="simple" > > required="false" > > /> > > <unnamed > > name="filetype" > > helpstring="A file type to show or ignore." > > many="true" > > required="false" > > /> > > <example> > > *********************************************** > > You may include any number of file types. > > By default, the types will be filtered from > > the list - use /s to filter all other types > > from the list. If no files types are > > indicated, then a full directory listing > > will be displayed. > > *********************************************** > > Example: > > dirfilter /d:c:\ /s js vbs wsf > > This will display all js, vbs, and wsf > > files in the directory. > > *********************************************** > > </example> > > </runtime> > > <object id="oShell" progid="WScript.Shell"/> > > <script language="JScript"> > > var i; // counting variable > > var bShow = WScript.Arguments.Named.Exists("s"); > > var cTypeCount = WScript.Arguments.Unnamed.length; > > if (0 == cTypeCount) > > bShow = false; > > var aList = new Array(cTypeCount); > > for (i = 0; i < cTypeCount; i++) > > aList[i] = WScript.Arguments.Unnamed(i); > > var sDir = oShell.CurrentDirectory; > > if (WScript.Arguments.Named.Exists("d")) > > sDir = WScript.Arguments.Named("d"); > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > var sText = ""; > > var quit = false; > > for (;;) > > { > > if (!oExec.StdOut.AtEndOfStream) > > sText += oExec.StdOut.ReadAll(); > > if (quit) break; > > if (oExec.status == 1) > > quit = true; > > else > > WScript.Sleep(100); > > } > > var aText = sText.split("\n"); > > var cTextCount = aText.length; > > sText = ""; > > for (i = 5; i < cTextCount - 3; i++) > > if (CheckLine(aText[i], aList, bShow)) > > sText += aText[i] + "\n"; > > WScript.Echo(sText); > > function CheckLine(sStr, aList, bShow) > > { > > var iExt = sStr.lastIndexOf(".") + 1; > > if (0 == iExt) > > return !bShow; > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > for (var i = 0; i < aList.length; i++) > > { > > if (sExt == aList[i]) > > return bShow; > > } > > return !bShow; > > } > > </script> > > </job> > > </package>
|
Sat, 11 Oct 2003 00:10:58 GMT |
|
 |
JJ #10 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Works for me. Did you execute it with cscript.exe? If you type "cscript" with no arguments, does it say version 5.6?
Quote: > I ran this code and got the following error > Object doesn't support this property or method: 'WshShell.Exec'
> > This script will execute a "dir" command and grab the output and then echo > > it back to stdout: > > Dim ExecObj > > Dim FromProc > > Set WshShell = WScript.CreateObject("WScript.Shell") > > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > > Do > > FromProc = ExecObj.StdOut.ReadLine() > > WScript.Echo FromProc > > Loop While Not ExecObj.Stdout.atEndOfStream > > Note that the above will blow up with an exception-type errror the first > > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > > enabled. It will run correctly in subsequent attempts because the first > > attempt locks a cscript.exe process in memory and this affects subsequent > > runs. But eventually the system will lock up solid because of it. It > only > > does this when you execute something through %COMSPEC% (command.com) or a > > 16-bit DOS application.
> > > Andrew Clinick describes WScript.Exec as a new method included in WSH > 5.6, > > > Beta 1. According to Clinick this method "introduces the ability to > start > > > programs or scripts in a command process that shares all the environment > > > variables of the parent script. It also allows the parent script to > > capture > > > any output from the child process." > > > I have been unable to find more information about WScript.Exec. My > > > unsuccessful research is listed below. Can anyone suggest additional > > > sources, or provided a simple example? > > > --- Unsuccessful research ----- > > > 1. Microsoft Knowledge base > > (http://search.support.microsoft.com/kb/c.asp). > > > Nothing comes up under "WScript.Exec" or "Exec" > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > wshtoc.htm) > > > "Exec" does not appear in the alphabetic keyword list. > > > 3. Clinick offer a code example by Michael Whalens. The following line > > > includes the first reference to the Exec method. See the complete > example > > at > > > the end of this post. > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > I rewrote Walens example as the following two line program, which > produced > > > the indicated error. I did not expect it to work. > > > set shell = createobject("WScript.shell") > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > Having no success finding the syntax of the exec method, I gave up. > > > --- complete Whalens example --- > > > <package> > > > <job id="ExecDemo"> > > > <runtime> > > > <description> > > > *********************************************** > > > * The Amazing Directory Filter Script!!!! * > > > *********************************************** > > > This script will filter out unwanted file > > > types from your directory listing, using the > > > powers of script and Windows Script Host. > > > *********************************************** > > > </description> > > > <named > > > name="d" > > > helpstring="The directory to list." > > > type="string" > > > required="false" > > > /> > > > <named > > > name="s" > > > helpstring="Show the extensions in the list." > > > type="simple" > > > required="false" > > > /> > > > <unnamed > > > name="filetype" > > > helpstring="A file type to show or ignore." > > > many="true" > > > required="false" > > > /> > > > <example> > > > *********************************************** > > > You may include any number of file types. > > > By default, the types will be filtered from > > > the list - use /s to filter all other types > > > from the list. If no files types are > > > indicated, then a full directory listing > > > will be displayed. > > > *********************************************** > > > Example: > > > dirfilter /d:c:\ /s js vbs wsf > > > This will display all js, vbs, and wsf > > > files in the directory. > > > *********************************************** > > > </example> > > > </runtime> > > > <object id="oShell" progid="WScript.Shell"/> > > > <script language="JScript"> > > > var i; // counting variable > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > if (0 == cTypeCount) > > > bShow = false; > > > var aList = new Array(cTypeCount); > > > for (i = 0; i < cTypeCount; i++) > > > aList[i] = WScript.Arguments.Unnamed(i); > > > var sDir = oShell.CurrentDirectory; > > > if (WScript.Arguments.Named.Exists("d")) > > > sDir = WScript.Arguments.Named("d"); > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > var sText = ""; > > > var quit = false; > > > for (;;) > > > { > > > if (!oExec.StdOut.AtEndOfStream) > > > sText += oExec.StdOut.ReadAll(); > > > if (quit) break; > > > if (oExec.status == 1) > > > quit = true; > > > else > > > WScript.Sleep(100); > > > } > > > var aText = sText.split("\n"); > > > var cTextCount = aText.length; > > > sText = ""; > > > for (i = 5; i < cTextCount - 3; i++) > > > if (CheckLine(aText[i], aList, bShow)) > > > sText += aText[i] + "\n"; > > > WScript.Echo(sText); > > > function CheckLine(sStr, aList, bShow) > > > { > > > var iExt = sStr.lastIndexOf(".") + 1; > > > if (0 == iExt) > > > return !bShow; > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > for (var i = 0; i < aList.length; i++) > > > { > > > if (sExt == aList[i]) > > > return bShow; > > > } > > > return !bShow; > > > } > > > </script> > > > </job> > > > </package>
|
Sat, 11 Oct 2003 10:40:15 GMT |
|
 |
JJ #11 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Jim, I hadn't tested this in a while, but I just tested it and it appears to be fixed - that is, NAV appears to be fixed. I am running NAV 2001 with all of the latest updates. My C program and the WSH script (using 5.6 beta 1) work fine now under Windows 98 even with auto-protect enabled.
Quote: > Yes, and this behavior was NOT fixed in beta 2. > And, btw, I have an app that does exactly that. However, if I run it using > the CreateProcess api (which I assume ms is using also), it runs just fine, > jw
> > This script will execute a "dir" command and grab the output and then echo > > it back to stdout: > > Dim ExecObj > > Dim FromProc > > Set WshShell = WScript.CreateObject("WScript.Shell") > > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > > Do > > FromProc = ExecObj.StdOut.ReadLine() > > WScript.Echo FromProc > > Loop While Not ExecObj.Stdout.atEndOfStream > > Note that the above will blow up with an exception-type errror the first > > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > > enabled. It will run correctly in subsequent attempts because the first > > attempt locks a cscript.exe process in memory and this affects subsequent > > runs. But eventually the system will lock up solid because of it. It > only > > does this when you execute something through %COMSPEC% (command.com) or a > > 16-bit DOS application.
> > > Andrew Clinick describes WScript.Exec as a new method included in WSH > 5.6, > > > Beta 1. According to Clinick this method "introduces the ability to > start > > > programs or scripts in a command process that shares all the environment > > > variables of the parent script. It also allows the parent script to > > capture > > > any output from the child process." > > > I have been unable to find more information about WScript.Exec. My > > > unsuccessful research is listed below. Can anyone suggest additional > > > sources, or provided a simple example? > > > --- Unsuccessful research ----- > > > 1. Microsoft Knowledge base > > (http://search.support.microsoft.com/kb/c.asp). > > > Nothing comes up under "WScript.Exec" or "Exec" > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > wshtoc.htm) > > > "Exec" does not appear in the alphabetic keyword list. > > > 3. Clinick offer a code example by Michael Whalens. The following line > > > includes the first reference to the Exec method. See the complete > example > > at > > > the end of this post. > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > I rewrote Walens example as the following two line program, which > produced > > > the indicated error. I did not expect it to work. > > > set shell = createobject("WScript.shell") > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > Having no success finding the syntax of the exec method, I gave up. > > > --- complete Whalens example --- > > > <package> > > > <job id="ExecDemo"> > > > <runtime> > > > <description> > > > *********************************************** > > > * The Amazing Directory Filter Script!!!! * > > > *********************************************** > > > This script will filter out unwanted file > > > types from your directory listing, using the > > > powers of script and Windows Script Host. > > > *********************************************** > > > </description> > > > <named > > > name="d" > > > helpstring="The directory to list." > > > type="string" > > > required="false" > > > /> > > > <named > > > name="s" > > > helpstring="Show the extensions in the list." > > > type="simple" > > > required="false" > > > /> > > > <unnamed > > > name="filetype" > > > helpstring="A file type to show or ignore." > > > many="true" > > > required="false" > > > /> > > > <example> > > > *********************************************** > > > You may include any number of file types. > > > By default, the types will be filtered from > > > the list - use /s to filter all other types > > > from the list. If no files types are > > > indicated, then a full directory listing > > > will be displayed. > > > *********************************************** > > > Example: > > > dirfilter /d:c:\ /s js vbs wsf > > > This will display all js, vbs, and wsf > > > files in the directory. > > > *********************************************** > > > </example> > > > </runtime> > > > <object id="oShell" progid="WScript.Shell"/> > > > <script language="JScript"> > > > var i; // counting variable > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > if (0 == cTypeCount) > > > bShow = false; > > > var aList = new Array(cTypeCount); > > > for (i = 0; i < cTypeCount; i++) > > > aList[i] = WScript.Arguments.Unnamed(i); > > > var sDir = oShell.CurrentDirectory; > > > if (WScript.Arguments.Named.Exists("d")) > > > sDir = WScript.Arguments.Named("d"); > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > var sText = ""; > > > var quit = false; > > > for (;;) > > > { > > > if (!oExec.StdOut.AtEndOfStream) > > > sText += oExec.StdOut.ReadAll(); > > > if (quit) break; > > > if (oExec.status == 1) > > > quit = true; > > > else > > > WScript.Sleep(100); > > > } > > > var aText = sText.split("\n"); > > > var cTextCount = aText.length; > > > sText = ""; > > > for (i = 5; i < cTextCount - 3; i++) > > > if (CheckLine(aText[i], aList, bShow)) > > > sText += aText[i] + "\n"; > > > WScript.Echo(sText); > > > function CheckLine(sStr, aList, bShow) > > > { > > > var iExt = sStr.lastIndexOf(".") + 1; > > > if (0 == iExt) > > > return !bShow; > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > for (var i = 0; i < aList.length; i++) > > > { > > > if (sExt == aList[i]) > > > return bShow; > > > } > > > return !bShow; > > > } > > > </script> > > > </job> > > > </package>
|
Sat, 11 Oct 2003 10:44:47 GMT |
|
 |
Keit #12 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Is COMSPEC misspelled? The code sample has %COMPSEC% I just downloaded the beta so I haven't tried it.
Quote: > Works for me. Did you execute it with cscript.exe? > If you type "cscript" with no arguments, does it say version 5.6?
> > I ran this code and got the following error > > Object doesn't support this property or method: 'WshShell.Exec'
Quote: > > > This script will execute a "dir" command and grab the output and then > echo > > > it back to stdout: > > > Dim ExecObj > > > Dim FromProc > > > Set WshShell = WScript.CreateObject("WScript.Shell") > > > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > > > Do > > > FromProc = ExecObj.StdOut.ReadLine() > > > WScript.Echo FromProc > > > Loop While Not ExecObj.Stdout.atEndOfStream > > > Note that the above will blow up with an exception-type errror the first > > > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect is > > > enabled. It will run correctly in subsequent attempts because the first > > > attempt locks a cscript.exe process in memory and this affects > subsequent > > > runs. But eventually the system will lock up solid because of it. It > > only > > > does this when you execute something through %COMSPEC% (command.com) or > a > > > 16-bit DOS application.
> > > > Andrew Clinick describes WScript.Exec as a new method included in WSH > > 5.6, > > > > Beta 1. According to Clinick this method "introduces the ability to > > start > > > > programs or scripts in a command process that shares all the > environment > > > > variables of the parent script. It also allows the parent script to > > > capture > > > > any output from the child process." > > > > I have been unable to find more information about WScript.Exec. My > > > > unsuccessful research is listed below. Can anyone suggest additional > > > > sources, or provided a simple example? > > > > --- Unsuccessful research ----- > > > > 1. Microsoft Knowledge base > > > (http://search.support.microsoft.com/kb/c.asp). > > > > Nothing comes up under "WScript.Exec" or "Exec" > > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > > wshtoc.htm) > > > > "Exec" does not appear in the alphabetic keyword list. > > > > 3. Clinick offer a code example by Michael Whalens. The following > line > > > > includes the first reference to the Exec method. See the complete > > example > > > at > > > > the end of this post. > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > I rewrote Walens example as the following two line program, which > > produced > > > > the indicated error. I did not expect it to work. > > > > set shell = createobject("WScript.shell") > > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > > Having no success finding the syntax of the exec method, I gave up. > > > > --- complete Whalens example --- > > > > <package> > > > > <job id="ExecDemo"> > > > > <runtime> > > > > <description> > > > > *********************************************** > > > > * The Amazing Directory Filter Script!!!! * > > > > *********************************************** > > > > This script will filter out unwanted file > > > > types from your directory listing, using the > > > > powers of script and Windows Script Host. > > > > *********************************************** > > > > </description> > > > > <named > > > > name="d" > > > > helpstring="The directory to list." > > > > type="string" > > > > required="false" > > > > /> > > > > <named > > > > name="s" > > > > helpstring="Show the extensions in the list." > > > > type="simple" > > > > required="false" > > > > /> > > > > <unnamed > > > > name="filetype" > > > > helpstring="A file type to show or ignore." > > > > many="true" > > > > required="false" > > > > /> > > > > <example> > > > > *********************************************** > > > > You may include any number of file types. > > > > By default, the types will be filtered from > > > > the list - use /s to filter all other types > > > > from the list. If no files types are > > > > indicated, then a full directory listing > > > > will be displayed. > > > > *********************************************** > > > > Example: > > > > dirfilter /d:c:\ /s js vbs wsf > > > > This will display all js, vbs, and wsf > > > > files in the directory. > > > > *********************************************** > > > > </example> > > > > </runtime> > > > > <object id="oShell" progid="WScript.Shell"/> > > > > <script language="JScript"> > > > > var i; // counting variable > > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > > if (0 == cTypeCount) > > > > bShow = false; > > > > var aList = new Array(cTypeCount); > > > > for (i = 0; i < cTypeCount; i++) > > > > aList[i] = WScript.Arguments.Unnamed(i); > > > > var sDir = oShell.CurrentDirectory; > > > > if (WScript.Arguments.Named.Exists("d")) > > > > sDir = WScript.Arguments.Named("d"); > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > var sText = ""; > > > > var quit = false; > > > > for (;;) > > > > { > > > > if (!oExec.StdOut.AtEndOfStream) > > > > sText += oExec.StdOut.ReadAll(); > > > > if (quit) break; > > > > if (oExec.status == 1) > > > > quit = true; > > > > else > > > > WScript.Sleep(100); > > > > } > > > > var aText = sText.split("\n"); > > > > var cTextCount = aText.length; > > > > sText = ""; > > > > for (i = 5; i < cTextCount - 3; i++) > > > > if (CheckLine(aText[i], aList, bShow)) > > > > sText += aText[i] + "\n"; > > > > WScript.Echo(sText); > > > > function CheckLine(sStr, aList, bShow) > > > > { > > > > var iExt = sStr.lastIndexOf(".") + 1; > > > > if (0 == iExt) > > > > return !bShow; > > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > > for (var i = 0; i < aList.length; i++) > > > > { > > > > if (sExt == aList[i]) > > > > return bShow; > > > > } > > > > return !bShow; > > > > } > > > > </script> > > > > </job> > > > > </package>
|
Sat, 11 Oct 2003 23:54:22 GMT |
|
 |
Adam D. Barrat #13 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
On Tue, 24 Apr 2001 11:54:22 -0400 in microsoft.public.scripting.wsh,
Quote: >Is COMSPEC misspelled? The code sample has %COMPSEC% >I just downloaded the beta so I haven't tried it.
It should indeed be %COMSPEC% hth hand -- Adam D. Barratt Please reply to the newsgroup rather than via e-mail
|
Sun, 12 Oct 2003 00:41:49 GMT |
|
 |
JJ #14 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Right - I typed it wrong. %COMSPEC%
Quote: > Is COMSPEC misspelled? The code sample has %COMPSEC% > I just downloaded the beta so I haven't tried it.
> > Works for me. Did you execute it with cscript.exe? > > If you type "cscript" with no arguments, does it say version 5.6?
> > > I ran this code and got the following error > > > Object doesn't support this property or method: 'WshShell.Exec'
> > > > This script will execute a "dir" command and grab the output and then > > echo > > > > it back to stdout: > > > > Dim ExecObj > > > > Dim FromProc > > > > Set WshShell = WScript.CreateObject("WScript.Shell") > > > > Set ExecObj = WshShell.Exec("%COMPSEC% /c dir") > > > > Do > > > > FromProc = ExecObj.StdOut.ReadLine() > > > > WScript.Echo FromProc > > > > Loop While Not ExecObj.Stdout.atEndOfStream > > > > Note that the above will blow up with an exception-type errror the > first > > > > time you run it on Windows 95/98/ME if Norton Anti-Virus auto protect > is > > > > enabled. It will run correctly in subsequent attempts because the > first > > > > attempt locks a cscript.exe process in memory and this affects > > subsequent > > > > runs. But eventually the system will lock up solid because of it. It > > > only > > > > does this when you execute something through %COMSPEC% (command.com) > or > > a > > > > 16-bit DOS application.
> > > > > Andrew Clinick describes WScript.Exec as a new method included in > WSH > > > 5.6, > > > > > Beta 1. According to Clinick this method "introduces the ability to > > > start > > > > > programs or scripts in a command process that shares all the > > environment > > > > > variables of the parent script. It also allows the parent script to > > > > capture > > > > > any output from the child process." > > > > > I have been unable to find more information about WScript.Exec. My > > > > > unsuccessful research is listed below. Can anyone suggest additional > > > > > sources, or provided a simple example? > > > > > --- Unsuccessful research ----- > > > > > 1. Microsoft Knowledge base > > > > (http://search.support.microsoft.com/kb/c.asp). > > > > > Nothing comes up under "WScript.Exec" or "Exec" > > > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > > > wshtoc.htm) > > > > > "Exec" does not appear in the alphabetic keyword list. > > > > > 3. Clinick offer a code example by Michael Whalens. The following > > line > > > > > includes the first reference to the Exec method. See the complete > > > example > > > > at > > > > > the end of this post. > > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > > I rewrote Walens example as the following two line program, which > > > produced > > > > > the indicated error. I did not expect it to work. > > > > > set shell = createobject("WScript.shell") > > > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > > > Having no success finding the syntax of the exec method, I gave up. > > > > > --- complete Whalens example --- > > > > > <package> > > > > > <job id="ExecDemo"> > > > > > <runtime> > > > > > <description> > > > > > *********************************************** > > > > > * The Amazing Directory Filter Script!!!! * > > > > > *********************************************** > > > > > This script will filter out unwanted file > > > > > types from your directory listing, using the > > > > > powers of script and Windows Script Host. > > > > > *********************************************** > > > > > </description> > > > > > <named > > > > > name="d" > > > > > helpstring="The directory to list." > > > > > type="string" > > > > > required="false" > > > > > /> > > > > > <named > > > > > name="s" > > > > > helpstring="Show the extensions in the list." > > > > > type="simple" > > > > > required="false" > > > > > /> > > > > > <unnamed > > > > > name="filetype" > > > > > helpstring="A file type to show or ignore." > > > > > many="true" > > > > > required="false" > > > > > /> > > > > > <example> > > > > > *********************************************** > > > > > You may include any number of file types. > > > > > By default, the types will be filtered from > > > > > the list - use /s to filter all other types > > > > > from the list. If no files types are > > > > > indicated, then a full directory listing > > > > > will be displayed. > > > > > *********************************************** > > > > > Example: > > > > > dirfilter /d:c:\ /s js vbs wsf > > > > > This will display all js, vbs, and wsf > > > > > files in the directory. > > > > > *********************************************** > > > > > </example> > > > > > </runtime> > > > > > <object id="oShell" progid="WScript.Shell"/> > > > > > <script language="JScript"> > > > > > var i; // counting variable > > > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > > > if (0 == cTypeCount) > > > > > bShow = false; > > > > > var aList = new Array(cTypeCount); > > > > > for (i = 0; i < cTypeCount; i++) > > > > > aList[i] = WScript.Arguments.Unnamed(i); > > > > > var sDir = oShell.CurrentDirectory; > > > > > if (WScript.Arguments.Named.Exists("d")) > > > > > sDir = WScript.Arguments.Named("d"); > > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > > var sText = ""; > > > > > var quit = false; > > > > > for (;;) > > > > > { > > > > > if (!oExec.StdOut.AtEndOfStream) > > > > > sText += oExec.StdOut.ReadAll(); > > > > > if (quit) break; > > > > > if (oExec.status == 1) > > > > > quit = true; > > > > > else > > > > > WScript.Sleep(100); > > > > > } > > > > > var aText = sText.split("\n"); > > > > > var cTextCount = aText.length; > > > > > sText = ""; > > > > > for (i = 5; i < cTextCount - 3; i++) > > > > > if (CheckLine(aText[i], aList, bShow)) > > > > > sText += aText[i] + "\n"; > > > > > WScript.Echo(sText); > > > > > function CheckLine(sStr, aList, bShow) > > > > > { > > > > > var iExt = sStr.lastIndexOf(".") + 1; > > > > > if (0 == iExt) > > > > > return !bShow; > > > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > > > for (var i = 0; i < aList.length; i++) > > > > > { > > > > > if (sExt == aList[i]) > > > > > return bShow; > > > > > } > > > > > return !bShow; > > > > > } > > > > > </script> > > > > > </job> > > > > > </package>
|
Sun, 12 Oct 2003 02:26:10 GMT |
|
 |
Fred #15 / 16
|
 WSH 5.6 Beta 1, new method, WScript.Exec
Will 5.6 work with Windows ME? Fred Jacobowitz
Quote: > The Knowledge Base (and pretty much all of the standard MSDN documentation) > is for released products. For beta products, you generally have to download > the beta documentation - searching the database won't find anything. Our > beta documentation is available on our beta download page - go to > http://msdn.microsoft.com/scripting, click on the link under "Windows Script > 5.6 Beta 2 Released", and the docs are at linked at the bottom of the page. > Mike Whalen > Windows Script Dev
> > Thanks Michael Harris. Getting the name right is helpful. However, > > searching the Microsoft knowledge base and the alphabetic keyword list of > > WSH elements for "WshShell.Exec" or "Exec" again produced no references. I > > do not use Visual Basic, or Visual Basic for Applications. I want to > > understand how this procedure works in several situations. For that I need > > the detailed syntax, and, hopefully, some examples. > > Any other suggestions.
> > > It's WshShell.Exec... Even the 5.6 beta docs slip up here and there > ;-). > > > The original spec may have been to have it be a method of WScript, but > it > > is definitely a method of > > > WshShell. Take a look with a VB/VBA Object Browser... And the object > > returned is a WshExec object, > > > not a WshScriptExec object... > > > -- > > > Michael Harris > > > Microsoft.MVP.Scripting > > > --
> > > Please do not email questions - post them to the newsgroup instead. > > > --
> > > > Andrew Clinick describes WScript.Exec as a new method included in WSH > > 5.6, > > > > Beta 1. According to Clinick this method "introduces the ability to > > start > > > > programs or scripts in a command process that shares all the > environment > > > > variables of the parent script. It also allows the parent script to > > capture > > > > any output from the child process." > > > > I have been unable to find more information about WScript.Exec. My > > > > unsuccessful research is listed below. Can anyone suggest additional > > > > sources, or provided a simple example? > > > > --- Unsuccessful research ----- > > > > 1. Microsoft Knowledge base > > (http://search.support.microsoft.com/kb/c.asp). > > > > Nothing comes up under "WScript.Exec" or "Exec" > > > > 2. WSH documentation
(http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshos... Quote: > > > > wshtoc.htm) > > > > "Exec" does not appear in the alphabetic keyword list. > > > > 3. Clinick offer a code example by Michael Whalens. The following > line > > > > includes the first reference to the Exec method. See the complete > > example at > > > > the end of this post. > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > I rewrote Walens example as the following two line program, which > > produced > > > > the indicated error. I did not expect it to work. > > > > set shell = createobject("WScript.shell") > > > > set oexec = shell.exec("%comspec% /c dir \"" + sDir + "\"") > > > > Type mismatch: '[string: "%comspec% /c dir \" "]' > > > > Having no success finding the syntax of the exec method, I gave up. > > > > --- complete Whalens example --- > > > > <package> > > > > <job id="ExecDemo"> > > > > <runtime> > > > > <description> > > > > *********************************************** > > > > * The Amazing Directory Filter Script!!!! * > > > > *********************************************** > > > > This script will filter out unwanted file > > > > types from your directory listing, using the > > > > powers of script and Windows Script Host. > > > > *********************************************** > > > > </description> > > > > <named > > > > name="d" > > > > helpstring="The directory to list." > > > > type="string" > > > > required="false" > > > > /> > > > > <named > > > > name="s" > > > > helpstring="Show the extensions in the list." > > > > type="simple" > > > > required="false" > > > > /> > > > > <unnamed > > > > name="filetype" > > > > helpstring="A file type to show or ignore." > > > > many="true" > > > > required="false" > > > > /> > > > > <example> > > > > *********************************************** > > > > You may include any number of file types. > > > > By default, the types will be filtered from > > > > the list - use /s to filter all other types > > > > from the list. If no files types are > > > > indicated, then a full directory listing > > > > will be displayed. > > > > *********************************************** > > > > Example: > > > > dirfilter /d:c:\ /s js vbs wsf > > > > This will display all js, vbs, and wsf > > > > files in the directory. > > > > *********************************************** > > > > </example> > > > > </runtime> > > > > <object id="oShell" progid="WScript.Shell"/> > > > > <script language="JScript"> > > > > var i; // counting variable > > > > var bShow = WScript.Arguments.Named.Exists("s"); > > > > var cTypeCount = WScript.Arguments.Unnamed.length; > > > > if (0 == cTypeCount) > > > > bShow = false; > > > > var aList = new Array(cTypeCount); > > > > for (i = 0; i < cTypeCount; i++) > > > > aList[i] = WScript.Arguments.Unnamed(i); > > > > var sDir = oShell.CurrentDirectory; > > > > if (WScript.Arguments.Named.Exists("d")) > > > > sDir = WScript.Arguments.Named("d"); > > > > var oExec = oShell.Exec("%comspec% /c dir \"" + sDir + "\""); > > > > var sText = ""; > > > > var quit = false; > > > > for (;;) > > > > { > > > > if (!oExec.StdOut.AtEndOfStream) > > > > sText += oExec.StdOut.ReadAll(); > > > > if (quit) break; > > > > if (oExec.status == 1) > > > > quit = true; > > > > else > > > > WScript.Sleep(100); > > > > } > > > > var aText = sText.split("\n"); > > > > var cTextCount = aText.length; > > > > sText = ""; > > > > for (i = 5; i < cTextCount - 3; i++) > > > > if (CheckLine(aText[i], aList, bShow)) > > > > sText += aText[i] + "\n"; > > > > WScript.Echo(sText); > > > > function CheckLine(sStr, aList, bShow) > > > > { > > > > var iExt = sStr.lastIndexOf(".") + 1; > > > > if (0 == iExt) > > > > return !bShow; > > > > var sExt = String(sStr.substring(iExt, sStr.length - 1)); > > > > for (var i = 0; i < aList.length; i++) > > > > { > > > > if (sExt == aList[i]) > > > > return bShow; > > > > } > > > > return !bShow; > > > > } > > > > </script> > > > > </job> > > > > </package>
|
Sun, 12 Oct 2003 04:31:39 GMT |
|
|
Page 1 of 2
|
[ 16 post ] |
|
Go to page:
[1]
[2] |
|