Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - diskpart and WshScriptExec problem

Reply
 
Old 09-19-2008   #1 (permalink)
James


 
 

diskpart and WshScriptExec problem

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.



My System SpecsSystem Spec
Old 09-19-2008   #2 (permalink)
James


 
 

Re: diskpart and WshScriptExec problem

just an update: if someone knows more please do share.

I've decided to just move the format operations outside of diskpart. My
hunch is that diskpart's format command is probably just actually calling
format.com anyway, which is what may be causing my problem with the
WshScriptExec object.... the program I execute (diskpart.exe) is calling
another program (format.com) and so the 'wiring' between the program and my
object get screwy? Thats my hunch, I have to move on. Again, if anyone else
has any input on this please do share.

thanks.

"James" <noone@xxxxxx> wrote in message
news:Og5LgIpGJHA.3576@xxxxxx
Quote:

> 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.
>

My System SpecsSystem Spec
Old 09-19-2008   #3 (permalink)
OldDog


 
 

Re: diskpart and WshScriptExec problem

On Sep 19, 2:58*pm, "James" <no...@xxxxxx> wrote:
Quote:

> 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 onit
> 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
My System SpecsSystem Spec
Old 09-19-2008   #4 (permalink)
James


 
 

Re: diskpart and WshScriptExec problem

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" <mikef2691@xxxxxx> wrote in message
news:90b469bd-2318-45e3-8e67-b36d3cbe3166@xxxxxx
On Sep 19, 2:58 pm, "James" <no...@xxxxxx> wrote:
Quote:

> 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


My System SpecsSystem Spec
Old 09-20-2008   #5 (permalink)
pooradmin


 
 

Re: diskpart and WshScriptExec problem

On Sep 19, 5:56*pm, "James" <no...@xxxxxx> wrote:
Quote:

> 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. Ido
> appreciate your response though. Thanks.
>
> "OldDog" <mikef2...@xxxxxx> wrote in message
>
> news:90b469bd-2318-45e3-8e67-b36d3cbe3166@xxxxxx
> On Sep 19, 2:58 pm, "James" <no...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > Hello,
>
Quote:

> > 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.
>
Quote:

> > 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 todo
> > 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.
>
Quote:

> > 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.
>
Quote:

> > thanks.
>
> You will probably need to Kill the Diskpart process after you quit.
>
> ' ProcessKillLocal.vbs
> ' Sample VBScript to kill a program
> ' Author Guy Thomashttp://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- Hide quoted text -
>
> - Show quoted text -
When run the same command outside of your script, same values etc. is
it waiting for any additional input when using diskpart before it hits
the exit?
My System SpecsSystem Spec
Old 09-22-2008   #6 (permalink)
James


 
 

Re: diskpart and WshScriptExec problem

good point, I just double-checked and no, its not awaiting input. Thanks for
the good thought though.

"pooradmin" <jskiba99@xxxxxx> wrote in message
news:35eac1cf-d47c-4074-a6dd-fd5b9aba87be@xxxxxx
On Sep 19, 5:56 pm, "James" <no...@xxxxxx> wrote:
Quote:

> 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" <mikef2...@xxxxxx> wrote in message
>
> news:90b469bd-2318-45e3-8e67-b36d3cbe3166@xxxxxx
> On Sep 19, 2:58 pm, "James" <no...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > Hello,
>
Quote:

> > 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.
>
Quote:

> > 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.
>
Quote:

> > 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.
>
Quote:

> > thanks.
>
> You will probably need to Kill the Diskpart process after you quit.
>
> ' ProcessKillLocal.vbs
> ' Sample VBScript to kill a program
> ' Author Guy Thomashttp://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- Hide quoted text -
>
> - Show quoted text -
When run the same command outside of your script, same values etc. is
it waiting for any additional input when using diskpart before it hits
the exit?


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Diskpart Mistake Vista General
Using Diskpart in VM's Virtual PC
Diskpart and Imagex Vista installation & setup
Diskpart utility Vista installation & setup
Diskpart Format command Vista General


Vista Forums 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 Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46