using DIR with wshshell.run 
Author Message
 using DIR with wshshell.run

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.*-*-*.com/


> > 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!



Sat, 14 Sep 2002 03:00:00 GMT  
 using DIR with wshshell.run
Quote:

> 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!



Sat, 14 Sep 2002 03:00:00 GMT  
 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!



Sun, 15 Sep 2002 03:00:00 GMT  
 using DIR with wshshell.run
Oops - replace Cmd with %Comspec%, it works... also, if you are not
including pass-back error handling, you might as well run that snippet of
code as a Sub instead of a Function too.
Steve
Quote:

>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



Sun, 15 Sep 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. using DIR with wshshell.run

2. using DIR with wshshell.run

3. using DIR with wshshell.run

4. WshShell.Run vs WshShell.Exec

5. runas with WshShell.Exec versus WshShell.Run

6. Using variables in WshShell.Run ("....")

7. Using a variable within WshShell object and Run method (newbie at work)

8. Using WshShell.Run with a shortcut

9. Opening a Program using WshShell.Run in an asp page

10. Syntax for running a command using WshShell

11. Using WshShell.Run to launch console app

12. using WshShell.Run - error returned

 

 
Powered by phpBB® Forum Software