![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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 Specs![]() |
| | #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 Specs![]() |
![]() |
| 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 |