c# - Loading bar while cmd.exe is running -


what i'm trying do:

pass command .cmd, show loading bar while command executes, exit cmd , display message box after progress bar full

what's happening:

when click button sends command, application hangs, command executed, cmd never exits after it's finished, application remains frozen (until manually close cmd.exe). have no idea how display loading bar while command executes. when loading bar full, that's when i'll display message box.

my code:

process p = new process(); p.startinfo.filename = "cmd.exe"; p.startinfo.workingdirectory = @"c:\" p.startinfo.windowstyle = processwindowstyle.normal; p.startinfo.useshellexecute = false; p.startinfo.redirectstandardoutput = true; p.startinfo.redirectstandardinput = true; p.startinfo.windowstyle = processwindowstyle.hidden; p.start(); p.standardinput.writeline(command_that's_called); 

^ gets executed upon button_click event.

things i've tried:

p.waitforexit(); // still hangs 

also threading, got error "accessed thread other 1 created on".

regarding cmd not closing, i'd kill after amount of time, length of time command complete depends on various things.

to exit cmd process after finished execute command, try add "/c" @ beginning of process arguments:

p.startinfo.arguments = "/c (your arguments)"; 

if type "cmd /?" in command prompt, you'll find "/c: carries out command specified string , terminates".

about add loadingbar, need learn backgroundworker class


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -