Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Powershell does not terminate when started VBSCRIPT

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 04-08-2007   #1 (permalink)
ktmd
Guest


 

Powershell does not terminate when started VBSCRIPT

I try to invoke Powershell command in a HTA application via VBSCRIPT. I see
Powershell command window opens, but it will not terminate. It just stay
open without any status.

For example, I have this test script named testposh.vbs. I ran it in a
command window as wscript testposh.vbs. Note that the test with ipconfig.exe
command works fine. (that cmdarg is commented out.)

how can I make powershell run the command and returns output to my vbscript?

---testposh.vbs ---
Set objShell = WScript.CreateObject("WScript.Shell")

'cmdarg = "%comspec% /c ipconfig.exe"

cmdarg = "%comspec% /c powershell -nologo -noninteractive -command ""2+2"""

wscript.echo cmdarg

Set objExecObject = objShell.Exec(cmdarg)

strLine =""
LineCnt=0
Do Until objExecObject.StdOut.AtEndOfStream
strLine = strLine & objExecObject.StdOut.ReadLine()
LineCnt= LineCnt + 1
Loop

Wscript.Echo "Linecount=" & LineCnt & ". Lines=" & strLine

---
thanks.


My System SpecsSystem Spec
Old 05-14-2007   #2 (permalink)
Guest


 

Re: Powershell does not terminate when started VBSCRIPT

I have this issue as well. Did you ever find a solution?

You can use the Run method of WScript.Shell, but I'd rather use Exec.

-- Sam

"ktmd" <ktmd@discussions.microsoft.com> wrote in message
news:AC0241A5-DEB1-4A2D-AB80-8C3E30C058D4@microsoft.com...
>I try to invoke Powershell command in a HTA application via VBSCRIPT. I
>see
> Powershell command window opens, but it will not terminate. It just stay
> open without any status.
>
> For example, I have this test script named testposh.vbs. I ran it in a
> command window as wscript testposh.vbs. Note that the test with
> ipconfig.exe
> command works fine. (that cmdarg is commented out.)
>
> how can I make powershell run the command and returns output to my
> vbscript?
>
> ---testposh.vbs ---
> Set objShell = WScript.CreateObject("WScript.Shell")
>
> 'cmdarg = "%comspec% /c ipconfig.exe"
>
> cmdarg = "%comspec% /c powershell -nologo -noninteractive -command
> ""2+2"""
>
> wscript.echo cmdarg
>
> Set objExecObject = objShell.Exec(cmdarg)
>
> strLine =""
> LineCnt=0
> Do Until objExecObject.StdOut.AtEndOfStream
> strLine = strLine & objExecObject.StdOut.ReadLine()
> LineCnt= LineCnt + 1
> Loop
>
> Wscript.Echo "Linecount=" & LineCnt & ". Lines=" & strLine
>
> ---
> thanks.
>


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Equivalent of powershell to vbscript command IT STAFF PowerShell 1 08-12-2008 05:08 AM
Return Powershell Error to VBscript bchad PowerShell 1 06-09-2008 02:26 PM
Re: VMware remote console causing powershell scripts to terminate? Maximilian Hänel PowerShell 6 03-11-2008 10:45 AM
VBScript vs. PowerShell error handling Matt PowerShell 3 07-02-2007 12:26 PM
PowerShell RC2 - Doc Bug in Getting Started? Andrew Watt [MVP] PowerShell 4 10-12-2006 04:22 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008