#86076 - 2002-06-13 09:55 PM
WSH Shell Piper
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Here is a script that pipes an error message using WSH. It's pretty cool because it doesn't use temp files or reg entries. Try it out and see what you think. If you guys like it, I'll turn it into a UDF.
code:
; Pipe.kix ; Break On $shellcmd="%comspec% /c dir *.kix" $WshShell=CreateObject("WScript.Shell") $oExec=$WshShell.Exec($shellcmd)
While $Exit<>1 Dim $Output $Output=ReadAll($oExec) If $Output=-1 If $oExec.Status=1 $Exit=1 endif Else ? $Output endif Loop
? "Exit Code: "+$oExec.ExitCode
Function ReadAll($oExec) If Not $oExec.StdOut.AtEndOfStream $ReadAll=$oExec.StdOut.ReadAll Exit endif If Not $oExec.StdErr.AtEndOfStream $ReadAll=$oExec.StdErr.ReadAll Exit endif $ReadAll=-1 EndFunction
|
Top
|
|
|
|
#86077 - 2002-06-13 09:59 PM
Re: WSH Shell Piper
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
do it!!!
Is it any slower? Does it open a cmd window? if not, is all the output is 'surpressed'/held internally?
does it pipe all normal output?
|
Top
|
|
|
|
#86080 - 2002-06-13 10:05 PM
Re: WSH Shell Piper
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
would this be like...
$result=wmicmd($command,$some options)
where $result[0] is the normal output and $result[1] is the error out?
|
Top
|
|
|
|
#86081 - 2002-06-13 10:07 PM
Re: WSH Shell Piper
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I agree as well. Publish
|
Top
|
|
|
|
#86082 - 2002-06-13 10:12 PM
Re: WSH Shell Piper
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I just went looking for "wmicmd" and could not find it. The only reference that search engine found was in this thread.
|
Top
|
|
|
|
#86085 - 2002-06-13 10:19 PM
Re: WSH Shell Piper
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
|
Top
|
|
|
|
#86086 - 2002-06-13 10:22 PM
Re: WSH Shell Piper
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
it works on my win2k sp2 IE6...
I Like it!!!
|
Top
|
|
|
|
#86092 - 2002-06-13 10:45 PM
Re: WSH Shell Piper
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I see.
Yeah, the ExitCode property was added with 5.6. With WSH 5.6 it is now possible to 1) Run a script on your computer that 2) loads a script from a second and 3) runs it on a third computer.
{Edit} Oh, and 5.6 comes with IE6. [ 13 June 2002, 22:47: Message edited by: Chris S. ]
|
Top
|
|
|
|
#86093 - 2002-06-13 10:51 PM
Re: WSH Shell Piper
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
|
Top
|
|
|
|
#86094 - 2002-06-13 11:01 PM
Re: WSH Shell Piper
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
just from the code that shawn posted I slammed this together, but I don't know enought to handle the error channel and such...
or the best way the pass the return back.
code:
break on
$return=WSHPipe("dir \\a06\logon\*.kix") ? $return
$pipearray=split($return,chr(10)) for each $line in $pipearray ? "."+$line next
get $k quit ;****************************************************************** function WSHPipe($cmd, Optional $environment) if $environment $cmd="/e $environment $cmd" endif $cmd="%comspec% /c "+$cmd $WshShell=CreateObject("WScript.Shell") $oExec=$WshShell.Exec("$cmd") $WSHPipe=$oExec.StdOut.ReadAll $WSHPipeErr=$oExec.StdErr.ReadAll endfunction
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|