Redirecting output from WshShell.RUN 
Author Message
 Redirecting output from WshShell.RUN

I'm a newbie at WSH, so please be gentle!  I'm trying to write a small
VBScript front end to the SRVINFO.EXE, found on the NT Resource Kit.  I want
the script to prompt for the Server name, and then, when running the
program, redirect the output to a text file.  However, it keeps giving the
usage of the command (i.e It doesn't work).  After a little troublshooting,
I figured out the problem is in the part of the command that redirects it to
the text file.  HELP! Below I've included the code.  I'd appreciate any
assistance.  Thanks.

'###CODE

DIM servername
servername=Inputbox("Enter name of Server you want to run SRVINFO.EXE on.",
"VBServer_Info")

if servername="" then
wscript.echo "No server name was entered; quiting program."
wscript.quit(1)
end if

Set WshShell=Wscript.CreateObject("Wscript.Shell")
WshShell.Run ("srvinfo \\" & servername & " " & "> " & servername & ".txt")



Sun, 11 Mar 2001 03:00:00 GMT  
 Redirecting output from WshShell.RUN
Try this line instead:

WshShell.Run ("cmd.exe /c srvinfo \\" & servername & " " & "> " & servername
& ".txt", ,True)

It's different in that it opens a command window and packs off a complete
line of code to its command line.

Regards,
Sen Hennessy



Sun, 11 Mar 2001 03:00:00 GMT  
 Redirecting output from WshShell.RUN
Nevermind... I figured it out.

WshShell.Run ("srvinfo \\" & servername & " " & "> " & servername & ".txt")

had to read:

WshShell.Run ("CMD /C srvinfo \\" & servername & " " & "> " & servername &
".txt")

(uppercase for my own notation)...seems that I needed to establish the
actual command environment.  Sorry .

Quote:

>I'm a newbie at WSH, so please be gentle!  I'm trying to write a small
>VBScript front end to the SRVINFO.EXE, found on the NT Resource Kit.  I
want
>the script to prompt for the Server name, and then, when running the
>program, redirect the output to a text file.  However, it keeps giving the
>usage of the command (i.e It doesn't work).  After a little troublshooting,
>I figured out the problem is in the part of the command that redirects it
to
>the text file.  HELP! Below I've included the code.  I'd appreciate any
>assistance.  Thanks.

>'###CODE

>DIM servername
>servername=Inputbox("Enter name of Server you want to run SRVINFO.EXE on.",
>"VBServer_Info")

>if servername="" then
>wscript.echo "No server name was entered; quiting program."
>wscript.quit(1)
>end if

>Set WshShell=Wscript.CreateObject("Wscript.Shell")
>WshShell.Run ("srvinfo \\" & servername & " " & "> " & servername & ".txt")



Sun, 11 Mar 2001 03:00:00 GMT  
 Redirecting output from WshShell.RUN
Thanks for the tip, but see my previous post.  Question though: What does
the TRUE do?

Quote:

>Try this line instead:

>WshShell.Run ("cmd.exe /c srvinfo \\" & servername & " " & "> " &
servername
>& ".txt", ,True)

>It's different in that it opens a command window and packs off a complete
>line of code to its command line.

>Regards,
>Sen Hennessy



Sun, 11 Mar 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Redirect WshShell.Run Output ?

2. How to return output from WshShell.Run??

3. wshShell.Run and saving output to an array

4. wshshell.run and output file

5. Redirecting run command line output from VBScript

6. Redirecting output from Run command

7. WshShell.Run vs WshShell.Exec

8. runas with WshShell.Exec versus WshShell.Run

9. wshshell.run: I can't run when there is a space in the path

10. Running COMMAND.COM with WshShell.Run

11. WshShell.Run don't run WHY ???

12. Batch file won't run with WshShell.run

 

 
Powered by phpBB® Forum Software