Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > diskpart and WshScriptExec problem

Reply
Thread Tools Display Modes

diskpart and WshScriptExec problem

 
 
James
Guest
Posts: n/a

 
      09-19-2008
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.


 
Reply With Quote
 
 
 
 
James
Guest
Posts: n/a

 
      09-19-2008
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" <> wrote in message
news:...
> 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.
>



 
Reply With Quote
 
James
Guest
Posts: n/a

 
      09-19-2008
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


 
Reply With Quote
 
James
Guest
Posts: n/a

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

"pooradmin" <> wrote in message
news:35eac1cf-d47c-4074-a6dd-...
On Sep 19, 5:56 pm, "James" <no...@nowhere.com> wrote:
> 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...@comcast.net> 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 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?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Diskpart 6.0 ? Meinolf Weber Windows Server 0 01-23-2008 07:52 PM
Problem with Diskpart since SP2 Kay Davis Windows Server 0 03-28-2007 08:42 PM
diskpart Exchange 2003 connection problem Windows Server 1 11-12-2005 04:04 PM
Problem with DISKPART - FSEXteND needed. Jacek Windows Server 2 01-07-2005 11:33 AM
StdOut(WshScriptExec) for 5.6 Scripting. Jerry Scripting 0 08-01-2003 10:04 PM



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 47 48 49 50 51 52 53 54 55 56 57 58 59