thanks for the input OldDog. The problem though is that I would'nt know
'when' to kill the process. It runs asynchronously from my main script. I do
appreciate your response though. Thanks.
"OldDog" <> wrote in message
news:90b469bd-2318-45e3-8e67-...
On Sep 19, 2:58 pm, "James" <no...@nowhere.com> wrote:
> Hello,
>
> currently putting together a vbscript that is piping input to diskpart.exe
> (from within winPE). It uses the WshScriptExec object with is sending
> input
> commands just fine. The problem I'm having is that even know I'm piping
> the
> 'exit' command to diskpart it does not exit... I still see it's process
> running in taskmgr... so my script loops infinitely waiting for that
> WshScriptExec.Status to change from 0, which it doesn't since diskpart
> does
> not exit. After I manually kill the task with taskmgr, my script breaks
> out
> of the loop as expected.
>
> the only command I'm sending diskpart that really takes any time is the
> format command. Thats where my loop comes in and just sleeps waiting for
> that WshScriptExec.status to change, signaling diskpart is done and has
> exited. I would really like to make this work the way I have set out to do
> but I know I have 2 other options: 1, do the format commands outside of
> diskpart with the 'run' instead of the 'exec' method. This would alow for
> running format.com synchronously eliminating the issue of not knowing when
> diskpart is done, or 2, instead of piping the diskpart commands
> interactively I could pipe them to a txt file which could then be supplied
> as script file param to diskpart, again, using run instead of exec so that
> its done synchronously.
>
> but again, I really like the way I started this... much cooler in my
> opinion, but I need to get this done so if anyone has any ideas as to why
> what I want to do is not working please let me know. I'm going to bail on
> it
> and move to an alternative by Monday.
>
> thanks.
You will probably need to Kill the Diskpart process after you quit.
' ProcessKillLocal.vbs
' Sample VBScript to kill a program
' Author Guy Thomas
http://computerperformance.co.uk/
' Version 2.7 - December 2005
' ------------------------ -------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'calc.exe'" <---- Diskpart.exe goes here
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer
WScript.Quit
' End of WMI Example of a Kill Process