Page 1 of 2 12>
Topic Options
#77044 - 2003-10-10 02:52 AM wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
I am trying to use the wshpipe function above and I am receiving the following error:
Script error : unknown command !
While Not $oExec.Status Loop

I am very new to this language, but I think I have do everything correctly. COuld anyone give me a bit of help?

As it says in the code i am using ie 6 sp1 and I do have the latest kixstart. So what do you guys think?

here is the code:

code:
  
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
While Not $oExec.Status Loop
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split($Output,CHR(10))
Exit($oExec.ExitCode)
EndFunction


break on
$tsProfilepath = "\\qas400\tsprofiles\"
$homedirpath = "\\qas400\user\"
$domain = @ldomain
$AD = getobject("WinNT://$domain")
for each $userobj in $AD
if $userobj.class="User"
$ouruser=$userobj.name
EndIf
if $ouruser="datalan"
? "Found user: "+$ouruser
$text=wshpipe("m:\winnt\tscmd.exe dc1nwbgh datalan terminalserverprofilepath")
? $text
endif
Next
$AD=""

Thanks.

-Nick

Top
#77045 - 2003-10-10 03:14 AM Re: wshpipe issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
what version of KiXtart are you using? You can find out by outputing the value of @kix.

What version of WSH is installed on the computer?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#77046 - 2003-10-10 03:17 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, try with changing this:
	$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
While Not $oExec.Status Loop


to:
	$oExec = CreateObject("WScript.Shell")
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Unsupported" Exit 10 EndIf
$oExec = $oExec.Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 11 EndIf
While Not $oExec.Status Loop
_________________________
!

download KiXnet

Top
#77047 - 2003-10-10 03:17 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
Kix is version 4.21
and wsh is 5.6

Thanks.

Top
#77048 - 2003-10-10 03:27 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
nick, you still there?
_________________________
!

download KiXnet

Top
#77049 - 2003-10-10 03:37 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
yes.

I will try it now.

-Nick

Top
#77050 - 2003-10-10 03:43 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
Same error message?
Top
#77051 - 2003-10-10 03:44 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what is the question mark there? [Confused]
_________________________
!

download KiXnet

Top
#77052 - 2003-10-10 03:51 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yet better one...
what it gives with:
	$oExec = CreateObject("WScript.Shell")
if @error "WScript.Shell error: " @error get $ exit 0 endif
$oExec = $oExec.Exec($ShellCMD)
if @error "WScript.Shell Exec error: " @error get $ exit 0 endif
While Not $oExec.Status Loop
_________________________
!

download KiXnet

Top
#77053 - 2003-10-10 03:52 AM Re: wshpipe issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Change you $ShellCMD from
quote:
"m:\winnt\tscmd.exe dc1nwbgh datalan terminalserverprofilepath"
to
quote:
"%comspec% /c dir c:\"
Does the same error occur? If you hit an account without a TS profile your program may be bring back an unexpected value or aborting.

I think once you get past this error you will find another with "? $text" since $text should be an array. You will have to use a "for each" loop.

[ 10. October 2003, 03:54: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#77054 - 2003-10-10 03:56 AM Re: wshpipe issues
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Can you execute the TSCMD.EXe with your parameters form the command line?

Put DEBUG ON into the first line of your code and step through the code. Evaluate each line to make sure it's executing correctly.
_________________________
There are two types of vessels, submarines and targets.

Top
#77055 - 2003-10-10 03:58 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yet better debug version (with wsh version and all [Wink] )
	$oExec = CreateObject("WScript.Shell")
if @error "WScript.Shell error: " @error get $ exit 0 endif
createobject("wscript").Version ?
$oExec = $oExec.Exec($ShellCMD)
if @error "WScript.Shell Exec error: " @error get $ exit 0 endif
While Not $oExec.Status Loop

updated code, it sucked.

[ 10. October 2003, 04:07: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#77056 - 2003-10-10 04:06 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
Ok,

Here is what I get now...

WScript.Shell Exec error: 1

[Smile]

Top
#77057 - 2003-10-10 04:08 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
just updated code.
_________________________
!

download KiXnet

Top
#77058 - 2003-10-10 04:10 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
After the update I get this...

Script error : unknown command !
createobject("wscript").Version ?

Top
#77059 - 2003-10-10 04:13 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
The command works at a command prompt. I did try with the following: "%comspec% /c dir c:\" and recieve the same error.

I stepped through the code and it stops at the
While Not $oExec.Status Loop line.

Thanks.

Top
#77060 - 2003-10-10 04:15 AM Re: wshpipe issues
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Are you sure WSH is correctly installed and enabled?

Try a shorter test script that just prints out the @KIX macro, initiates the WSH COM object, and so on. E.g.
code:
break on
? 'KiXtart = '+@KIX
$oWSH=createobject('WScript')
? ''+@ERROR+' - '+@SERROR
? 'WSH = '+$oWSH.Version
exit 0

Report back the complete output.

[ 10. October 2003, 04:24: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#77061 - 2003-10-10 04:18 AM Re: wshpipe issues
nicktech Offline
Fresh Scripter

Registered: 2003-10-09
Posts: 12
Loc: White Plains, NY
KiXtart = 4.02
-2147221005 - Invalid class string
Script error : unknown command !
? WSH = '+$oWSH.Version

Top
#77062 - 2003-10-10 04:24 AM Re: wshpipe issues
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Two things. First you are not running KiXtart 4.21 as you stated and it looks like you DO NOT have WSH 5.6 installed.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#77063 - 2003-10-10 04:26 AM Re: wshpipe issues
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol.
I realized too that we can't get to wscript object.
thus we can't get to version info either:
quote:

The WScript object cannot be instantiated directly using CreateObject, however scripts running under WSH can obtain a reference to it via the Application property.

Through the WScript object one can gain access to WSH version information

http://www.devguru.com/Technologies/wsh/quickref/wscript.html

[ 10. October 2003, 04:26: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 765 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.126 seconds in which 0.075 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org