
using DIR with wshshell.run
Matt -
I was having the same difficulty, since VB Script does not appear to
directly support the simple DIR command. Below is basically the code I used
on an NT 4 workstation which works with just VB Script. I am using WSH
version 5.1, though I don't believe that makes a difference. I believe this
will work for most DOS-based commands. Of course, you can add whatever
options you desire. Happy coding!
Steve
Dim vFunctionReturn
vFunctionReturn = FileList()
Function FileList()
Dim oShell
Dim vReturn
Set oShell = Wscript.CreateObject("Wscript.Shell')
vReturn = oShell.Run("Cmd /c DIR *.ASP /B /S > FileList.txt", 0, True)
End Function
Quote:
>> how about in vbscript?
>> --dir.wsf---
>> <job>
>> <script language='JScript'>
>> var wshshell = new ActiveXObject("WScript.Shell");
>> wshshell.run("%comspec% /c DIR *.PAB /o /l /b /s > foo.txt", 0, true);
>> </script>
>> </job>
>> ---end--
>> Run this from the root of the folders of interest.
>> --
>> Mark L. Ferguson Please reply in newsgroup
>> marfers notes for OE5 >
>> http://www.geocities.com/SiliconValley/Bay/6386/IE_ng_notes.htm
>> > I need to know how to execute the dir command from WSH. What I want to
>do
>> > is a DIR *.PAB /o /l /b /s > foo.txt
>> > what's the best way to do this?
>> > thanks!